[C#] 纯文本查看 复制代码
protected HttpItem m_httpitem = new HttpItem()
{
URL = "",//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Timeout = 4000,//连接超时时间 可选项默认为100000 2000
ReadWriteTimeout = 5000,//写入Post数据超时时间 可选项默认为30000 3000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
//Cookie = "",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Referer = "",//来源URL 可选项
Allowautoredirect = false,//是否根据301跳转 可选项
AutoRedirectCookie = false,//是否自动处理Cookie 可选项
//CerPath = "d:\123.cer",//证书绝对路径 可选项不需要证书时可以不写这个参数
//Connectionlimit = 1024,//最大连接数 可选项 默认为1024
Postdata = "",//Post数据 可选项GET时不需要写
//ProxyIp = "127.0.0.1:8888",//代理服务器ID 可选项 不需要代理 时可以不设置这三个参数
//ProxyPwd = "123456",//代理服务器密码 可选项
//ProxyUserName = "administrator",//代理服务器账户名 可选项
ResultType = ResultType.String,//返回数据类型,是Byte还是String
CookieCollection = null,
ResultCookieType = ResultCookieType.CookieCollection
};
m_httpitem.CookieCollection = new CookieCollection();
//m_httpitem.Allowautoredirect = true;//是否根据301跳转 可选项
//m_httpitem.AutoRedirectCookie = true;//是否自动处理Cookie 可选项
//直接访问B站,获取Cookie
m_httpitem.URL = m_loginParam.url[m_urlcur] + "/ssid1?url=/";
m_httpitem.Referer = "";
HttpResult result = m_http.GetHtml(m_httpitem);
//设置获取到的Cookie
m_httpitem.CookieCollection.Add(result.CookieCollection);
//返回访问A站 ----此步骤查看监控,cookie没有带上
m_httpitem.URL = m_loginParam.url[m_urlcur];
m_httpitem.Referer = "";
result = m_http.GetHtml(m_httpitem);
if (result.StatusCode != System.Net.HttpStatusCode.OK || result.Html == null)
{
return string.Empty;
}