|
1金钱
用HttpHelper模拟12306请求 查询余票信息,一直不成功,请大神赐教
HttpHelper http_init = new HttpHelper();
HttpItem item_init = new HttpItem()
{
URL = "https://kyfw.12306.cn/otn/lcxxcx/init",//URL 必需项
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
KeepAlive=true,
CerPath = "C:\\zs.cer",
Method = "get",
UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:37.0) Gecko/20100101 Firefox/37.0",
Allowautoredirect = false
};
HttpResult result_init = http_init.GetHtml(item_init);
string logincookie=result_init.Cookie;
////
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://kyfw.12306.cn/otn/lcxxcx/query",
Accept="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
CerPath="C:\\zs.cer",
KeepAlive = true,
Method = "get",
Cookie = logincookie,//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:37.0) Gecko/20100101 Firefox/37.0",
ContentType = "application/x-www-form-urlencoded",
Postdata = "purpose_codes=ADULT&queryDate=2015-05-13&from_station=SHH&to_station=BJP",
Allowautoredirect = false
};
HttpResult result = http.GetHtml(item);
string cookie = "";
一下是返回信息
{\"validateMessagesShowId\":\"_validatorMessage\",\"url\":\"/leftTicket/init\",\"status\":false,\"httpstatus\":200,\"messages\":[\"系统忙,请稍后重试\"],\"validateMessages\":{}}
|
|