为了账号安全,请及时绑定邮箱和手机立即绑定

网页爬虫探讨 request response

网页爬虫探讨 request response

蝴蝶不菲 2018-12-07 02:20:50
请问,这样写有没有问题??? 1 string parm = "beginDate=" + date + "&endDate=" + date + "&spnrtype=ALL&sstatus=ALL&refund_status=ALL&booking_no=" + pnr + "&bank_order_no=&usrid=&tickettype=ALL&ettype=ALL&isrefund=1&ismuerrorrefund=1&pnrtype=&actiontype=query&subtpList="; 2 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://mu.travelsky.com/muair/servlet/com.muet.model.login.LoginServlet?" + logString); 3 request.Accept = "*/*"; 4 request.Method = "POST"; 5 request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"; 6 response.Cookies = cc.GetCookies(request.RequestUri); 7 request.CookieContainer = cc; 8 request.KeepAlive = true; 9 request.Referer = "http://mu.travelsky.com/muair/Query/front/pnrquery.jsp";10 byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes(parm);11 request.ContentLength = bytes.Length;12 request.ContentType = "application/x-www-form-urlencoded";13 14 Stream stream = request.GetRequestStream();15 stream.Write(bytes,0,bytes.Length);16 stream.Close();17 18 HttpWebResponse response = (HttpWebResponse)request.GetResponse();19 response.Cookies = cc.GetCookies(request.RequestUri);20 request.CookieContainer = cc;21 22 StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);23 string content = reader1.ReadToEnd();24 reader.Close();  
查看完整描述

2 回答

?
青春有我

TA贡献1784条经验 获得超8个赞

兄弟  你也是做机票的啊,想拉东航的PNR数据啊?

查看完整回答
反对 回复 2019-01-21
?
ABOUTYOU

TA贡献1812条经验 获得超5个赞

有没有问题你运行一下不就知道了。

查看完整回答
反对 回复 2019-01-21
  • 2 回答
  • 0 关注
  • 463 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信