本文整理汇总了C#中System.Net.CookieContainer.zAdd方法的典型用法代码示例。如果您正苦于以下问题:C# CookieContainer.zAdd方法的具体用法?C# CookieContainer.zAdd怎么用?C# CookieContainer.zAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.CookieContainer
的用法示例。
在下文中一共展示了CookieContainer.zAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Handeco_Load_WebRequest_01
public static void Test_Handeco_Load_WebRequest_01()
{
string outputFile = @"test\handeco.html";
string url = "http://www.handeco.org/fournisseurs/rechercher";
string content = "raisonSociale=&SIRET=&departements%5B%5D=03&experience_cotraitance=0&motsCles=&submitRecherche=Rechercher";
//string cookies = "PHPSESSID=572851556c8b3b2ef74692a0b1de6675; __utma=140104362.2125206869.1396505609.1396505609.1396505609.1; __utmc=140104362; __utmz=140104362.1396505609.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)";
string cookies = "PHPSESSID=572851556c8b3b2ef74692a0b1de6675; __utma=140104362.2125206869.1396505609.1396520128.1396528821.5; __utmb=140104362.1.10.1396528821; __utmc=140104362; __utmz=140104362.1396505609.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)";
string userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36 CoolNovo/2.0.9.20";
System.Net.WebRequest webRequest = System.Net.WebRequest.Create(url);
System.Net.HttpWebRequest httpWebRequest = webRequest as System.Net.HttpWebRequest;
httpWebRequest.ServicePoint.Expect100Continue = false;
httpWebRequest.UserAgent = userAgent;
//httpWebRequest.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
httpWebRequest.Referer = "http://www.handeco.org/fournisseurs/rechercher";
//httpWebRequest.Headers.Add(_requestParameters.headers);
System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();
cookieContainer.zAdd(url, cookies);
httpWebRequest.CookieContainer = cookieContainer;
// Content-Type: application/x-www-form-urlencoded
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
Encoding encoding = Encoding.Default;
byte[] bytes = encoding.GetBytes(content);
httpWebRequest.ContentLength = bytes.LongLength;
System.IO.Stream stream = httpWebRequest.GetRequestStream();
using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(stream))
{
w.Write(bytes);
}
System.Net.WebResponse webResponse = webRequest.GetResponse();
stream = webResponse.GetResponseStream();
System.IO.StreamReader webStream = new System.IO.StreamReader(stream, encoding);
string textResult = webStream.ReadToEnd();
outputFile = GetPath(outputFile);
zfile.WriteFile(outputFile, textResult);
// Connection: keep-alive
httpWebRequest.KeepAlive = true;
// Cache-Control: max-age=0
// Origin: http://www.handeco.org
// Accept-Encoding: gzip,deflate,sdch
// Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
//httpWebRequest.CachePolicy
//httpWebRequest.Headers
//httpWebRequest.Host
}