两个关联页面的动态数据抓取

qq_28750173 2015-12-05 12:42:00
第一个页面输入查询条件后点击查询 跳转到第二个页面生成查询数据
怎么抓取第二个页面的数据
我是新手刚开始做这个 希望给我些提示
...全文
95 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_28053691 2015-12-09
  • 打赏
  • 举报
回复
public string flightSearch(string oneway,string orgcity,string dstcity,string flightdate) { string Url = "https://www.urumqi-air.com/flight/searchflight!getFlights.action"; //string Referer = "https://www.urumqi-air.com/flight/searchflight.action?tripType="+oneway+"&orgCity1="+orgcity+"&dstCity1="+dstcity+"&flightdate1="+flightdate+"&flightdate2="; string PostData = "<flight><tripType>"+oneway+"</tripType><orgCity1>"+orgcity+"</orgCity1><dstCity1>"+dstcity+"</dstCity1><flightdate1>"+flightdate+"</flightdate1><index>1</index></flight>"; string flights = post(Url, PostData); return flights; } public string post(string url, string str) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Method = "POST"; req.Host = "www.urumqi-air.com"; req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:41.0) Gecko/20100101 Firefox/41.0"; req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; //req.Referer = refer; byte[] buf = Encoding.UTF8.GetBytes(str); req.ContentLength = buf.Length; using (Stream s = req.GetRequestStream()) { s.Write(buf, 0, buf.Length); } HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); using (Stream s = resp.GetResponseStream()) { using (StreamReader sr = new StreamReader(s)) { return sr.ReadToEnd(); } } }
qq_28750173 2015-12-05
  • 打赏
  • 举报
回复
比如:http://www.urumqi-air.com/ 打开后选择搜索数据 点击搜索 跳转到另一个页面 获得跳转后的页码的数据 才学习这个 不怎么懂 希望具体的思路和操作问题给我解析一下 小弟感激不尽

70,026

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧