个别网页关键的会话部分抓不下来,有经验的进来分析一下!

qingtianzhuren 2005-10-18 04:01:33
下面是一个抓问天网天气预报的函数,但用下面这个,“未找到城市”,关键的你想得到的城市天气预报信息没有,不知哪个环节出了问题,大家讨论一下吧!
Public Shared Function GetWeb2(ByVal strUrl As String) As String
Dim city() As String = {"济南", "莱芜", "青岛", "淄博", "德州", "聊城", "菏泽", "泰安", "济宁", "临沂", "枣庄", "日照", "威海", "烟台", "东营", "潍坊", "滨州"}
Dim i As Integer
Dim strResult As String
Try
Dim uri As New uri(strUrl)
Dim res As System.Net.HttpWebResponse
Dim paramList As String = uri.Query
Dim req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(uri)
req.Method = "GET"
req.Connection = "KeepAlive"
req.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*"
req.Referer = "http://weather.tq121.com.cn/panel/index1.php?city=%B6%AB%D3%AA&submit=%CB%D1%CB%D1"
req.AllowAutoRedirect = True
req.ContentType = "application/x-www-form-urlencoded"
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
req.Headers.Add("Accept-Language", "zh-cn")
Dim reserved() As Char = {"?", "=", "&"}
Dim SomeBytes() As Byte
Dim UrlEncoded As New System.Text.StringBuilder
res = req.GetResponse()
Dim ReceiveStream As System.IO.Stream = res.GetResponseStream()
Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("gb2312")
Dim sr As New System.IO.StreamReader(ReceiveStream, encode)
strResult = sr.ReadToEnd()
Catch e As Exception
Console.WriteLine(e.ToString)

End Try

Return strResult

End Function
...全文
48 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
自由程序员 2005-10-18
  • 打赏
  • 举报
回复
用offline explorer下下来分析目录结构

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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