如何获得Google搜索结果页面的网页源码?我用inet和XMLHTTP都告诉我说拒绝的权限,下载不到网页源码
本帖最后由 zyhyr119686 于 2013-08-14 18:32:07 编辑 如何获得Google搜索结果页面的网页源码?比如这个地址的网页源码:http://www.google.com.hk/search?q=site:http://www.justcon.net mail&hl=zh-CN&newwindow=1&biw=1218&bih=539&num=100&lr=&ft=i&cr=l1
我用inet和XMLHTTP都告诉我说拒绝的权限,下载不到网页源码.就是比如用这个代码你是下载不到网页源码的:
mail = Inet1.OpenURL("http://www.google.com.hk/search?q=site:http://www.justcon.net mail&hl=zh-CN&newwindow=1&biw=1218&bih=539&num=100&lr=&ft=i&cr=l1")
Text5 = mail
Private Sub Command1_Click()
Text1 = ""
DoEvents
Dim GetUrl$, ReturnCode$
GetUrl = "http://www.google.com.hk/search?q=site:http://www.justcon.net?mail&hl=zh-CN&newwindow=1&biw=1218&bih=539&num=100&lr=&ft=i&cr=l1"
ReturnCode = GetByWinHttp(GetUrl)
Debug.Print ReturnCode
Text1 = ReturnCode
Text1.SelText = ReturnCode
End Sub
Function GetByWinHttp$(ByVal GetUrl$)
On Error Resume Next
Dim XmlHttp As Object
Set XmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
With XmlHttp
.Open "GET", GetUrl, True
.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0E; .NET4.0C)"
.Send
.WaitForResponse
GetByWinHttp = .ResponseText
End With
Set XmlHttp = Nothing
End Function