首页 新闻 会员 周边 捐助

网页爬虫探讨 request response

0
悬赏园豆:10 [已解决问题] 解决于 2011-01-17 09: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();

 

1行受影响的主页 1行受影响 | 初学一级 | 园豆:113
提问于:2011-01-07 09:39
< >
分享
最佳答案
0

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

收获园豆:10
头衔 | 菜鸟二级 |园豆:364 | 2011-01-07 11:55
对,你也是。。有什么可以借鉴的。我们相互沟通下,加我QQ 172035076
1行受影响 | 园豆:113 (初学一级) | 2011-01-10 09:32
单位不允许上QQ,没办法!发站内信吧
头衔 | 园豆:364 (菜鸟二级) | 2011-01-14 10:03
其他回答(1)
0

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

Astar | 园豆:40805 (高人七级) | 2011-01-07 14:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册