[C#] 纯文本查看 复制代码 private void button1_Click(object sender, EventArgs e)
{
Getcookie myget = new Getcookie();
//richTextBox1.Text += myget.GetCookieString(textBox1.Text.Trim());
richTextBox1.Text += Gethtml();
// Hide();
}
public string Gethtml()
{
Getcookie myget = new Getcookie();
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://s.taobao.com/search?q=t恤男",//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie =" t = 57beb9b27b0d36dcf80c0bc9e505ae7b; cna = UCBDFd4lBFUCARsd3N3Mm2wQ; tg = 0; thw = cn; enc = 0omffYHF9R % 2B0wxG3PVgDbhJmqFaGzILYpcirgK1MRSkDEMIuZi3z21txnYWnBpjGSoTp0LTAbvZQ901 % 2F3nwmqQ % 3D % 3D; hng = CN % 7Czh - CN % 7CCNY % 7C156; _m_h5_tk = c8988930e7681ef2ad533a23acbb6d07_1556083076495; _m_h5_tk_enc = 26a082bd7ca949a1cd1c841ac3e52b03; tracknick =% 5Cu5929 % 5Cu610F188881; lgc =% 5Cu5929 % 5Cu610F188881; mt = ci = 58_1 & np =; v = 0; cookie2 = 5596aca4d385821d90b5f117673c6713; _tb_token_ = ee13e0e3beeb8; _mw_us_time_ = 1556355518629; unb = 369109889; uc1 = cookie16 = W5iHLLyFPlMGbLDwA % 2BdvAGZqLg % 3D % 3D & cookie21 = VFC % 2FuZ9ajCbF8 % 2BYOUZmuyA % 3D % 3D & cookie15 = WqG3DMC9VAQiUQ % 3D % 3D & existShop = true & pas = 0 & cookie14 = UoTZ4tAvVRYbTg % 3D % 3D & tag = 8 & lng = zh_CN; sg = 199; _l_g_ = Ug % 3D % 3D; skt = 69d94d3ee4b92dcc; cookie1 = Vvj6Rp % 2Bf5UYX4SVumR8mjQDHchRapVf1FvRSEietIis % 3D; csg = d8c148c8; uc3 = vt3 = F8dByEfCF6F03h05Tsc % 3D & id2 = UNaOmmIt6gkb & nk2 = r7k0NKNDgNMyIg % 3D % 3D & lg2 = U % 2BGCWk % 2F75gdr5Q % 3D % 3D; existShop = MTU1NjM1NTUyMA % 3D % 3D; _cc_ = UIHiLt3xSw % 3D % 3D; dnk =% 5Cu5929 % 5Cu610F188881; _nk_ =% 5Cu5929 % 5Cu610F188881; cookie17 = UNaOmmIt6gkb; l = bBxJAjC4vlre - JytBOCanurza77OSIRYYuPzaNbMi_5dp6T_D87OlQpI5F96Vj5R_TYB4keiqTJ9 - etkZ; isg = BM_PEIYAzwK0zMsG40uvEmIPXmMZXCFwrH8zj - Hcaz5FsO - y6cSzZs2itqCryPuO",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
Referer = "",//来源URL 可选项
Postdata = "",//Post数据 可选项GET时不需要写
//ProxyIp = "192.168.1.105:2020",//代理服务器ID 可选项 不需要代理 时可以不设置这三个参数
//ProxyPwd = "123456",//代理服务器密码 可选项
//ProxyUserName = "administrator",//代理服务器账户名 可选项
ResultType = ResultType.String,//返回数据类型,是Byte还是String
};
HttpResult result = http.GetHtml(item);
string html = result.Html;
return html;
}
这样手动填入cookie才可以获取到,老师,是我那里没弄懂吗?怎么不能用表达式了? |