|
本帖最后由 pyengwoei 于 2017-5-11 18:35 编辑
using CsharpHttpHelper;
using CsharpHttpHelper.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace testfff
{
class Program
{
static void Main(string[] args)
{
string cookie = "";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://www.365-808.com/?&cb=10581218126",
Method = "GET",//URL 可选项 默认为Get
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "aps03=cg=0&cst=0&ct=42&lng=1;pstk=3C5A7056C6DC7CF8831EC66A2905D925000003;session=flslnk=%23HO%23&psite=1;cp2=0; rmbs=3",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
Referer = "https://www.365-808.com/en/",//来源URL 可选项
Allowautoredirect = true,//是否根据301跳转 可选项
AutoRedirectCookie = true,//是否自动处理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
//ResultCookieType = ResultCookieType.CookieCollection
};
HttpResult result = http.GetHtml(item);
string html = result.Html;
cookie = result.Cookie;
CookieCollection CookiesJar = new CookieCollection();
CookiesJar =HttpHelper.StrCookieToCookieCollection(cookie);
}
}
}返回的cookie 应该是这些:
rmbs=3; expires=Sat, 11-Nov-2017 00:00:00 GMT; path=/,session=flslnk=&processform=0&id=%7B5A50A4A1%2D4648%2D475B%2D990A%2DCEC18731678C%7D&psite=1; path=/,pstk=F5A934E86C74457D81CFAB53A9EB64FE000003; domain=365-808.com; path=/,aps03=oty=1&cg=0&cst=0&cf=N&ct=42&tzi=27&hd=N&lng=1; expires=Mon, 10-May-2027 23:00:00 GMT; path=/
CookiesJar 得到的count是2
{rmbs=3}
{pstk=F5A934E86C74457D81CFAB53A9EB64FE000003}
这两个 好像不对啊
|
|