|
楼主 |
发表于 2019-3-6 12:31:23
|
显示全部楼层
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://cn.investing.com/instruments/HistoricalDataAjax",//URL 必需项
Method = "POST",//URL 可选项 默认为Get
//Cookie = "PHPSESSID=2qo7vvc5n23d8v0o9eu3c3qjvj; SideBlockUser=a%3A2%3A%7Bs%3A10%3A%22stack_size%22%3Ba%3A1%3A%7Bs%3A11%3A%22last_quotes%22%3Bi%3A8%3B%7Ds%3A6%3A%22stacks%22%3Ba%3A1%3A%7Bs%3A11%3A%22last_quotes%22%3Ba%3A1%3A%7Bi%3A0%3Ba%3A3%3A%7Bs%3A7%3A%22pair_ID%22%3Bs%3A5%3A%2224698%22%3Bs%3A10%3A%22pair_title%22%3Bs%3A0%3A%22%22%3Bs%3A9%3A%22pair_link%22%3Bs%3A20%3A%22%2Fequities%2Fair-canada%22%3B%7D%7D%7D%7D; geoC=CN; adBlockerNewUserDomains=1551823209; StickySession=id.12798334160.707cn.investing.com; _ga=GA1.2.2024766661.1551823218; _gid=GA1.2.841496107.1551823218; _gat=1; _gat_allSitesTracker=1; Hm_lvt_a1e3d50107c2a0e021d734fe76f85914=1551823218; __gads=ID=f46149f8a3cffd5a:T=1551823219:S=ALNI_MZbklvZdwl0YmGKxZVXurKoSH_bFQ; __qca=P0-82017016-1551823218759; billboardCounter_6=0; __atuvc=3%7C10; __atuvs=5c7ef171c8c1327c002; Hm_lpvt_a1e3d50107c2a0e021d734fe76f85914=1551823234; nyxDorf=ZGAzZDZ%2BYz00YGhkYC0xMmIyZDsyKzo5Njc0Mg%3D%3D",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/plain, */*; q=0.01",// 可选项有默认值
Allowautoredirect = false,//是否根据301跳转 可选项
AutoRedirectCookie = true,//是否自动处理Cookie 可选项
//CerPath = "d:\123.cer",//证书绝对路径 可选项不需要证书时可以不写这个参数
//Connectionlimit = 1024,//最大连接数 可选项 默认为1024
Postdata = "curr_id=24698&smlID=1169236&header=AC%E5%8E%86%E5%8F%B2%E6%95%B0%E6%8D%AE&st_date=2019%2F02%2F03&end_date=2019%2F03%2F05&interval_sec=Daily&sort_col=date&sort_ord=DESC&action=historical_data",//Post数据 可选项GET时不需要写
//ProxyIp = "192.168.1.105:2020",//代理服务器ID 可选项 不需要代理 时可以不设置这三个参数
//ProxyPwd = "123456",//代理服务器密码 可选项
//ProxyUserName = "administrator",//代理服务器账户名 可选项
ResultType = ResultType.String,//返回数据类型,是Byte还是String
};
item.Header.Add("Origin", " https");//设置请求头信息(Header)
item.Header.Add("Accept-Encoding", " gzip");//设置请求头信息(Header)
HttpResult result = http.GetHtml(item);
string html = result.Html;
string cookie = result.Cookie;
MessageBox.Show(html); |
|