VB不用WebBrowser1控件获取网页文本
用控件是这样Text1.Text=WebBrowser1.Document.body.innertext请问不用WebBrowser1控件可以获取吗/可以的话发下代码,谢...
用控件是这样 Text1.Text = WebBrowser1.Document.body.innertext
请问不用WebBrowser1控件可以获取吗/
可以的话发下代码,谢谢 展开
请问不用WebBrowser1控件可以获取吗/
可以的话发下代码,谢谢 展开
展开全部
不用控件就可以,代码如下:
Private Sub Command1_Click()
URL = "http://www.qq.com"
Set xmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
xmlHttp.open "GET", Trim(URL), False
xmlHttp.send
text1.text=BytesToBstr(xmlHttp.responsebody, "UTF-8")
End Sub
'远程获取网页编码格式转换
Function BytesToBstr(body, charset) '转换成需要的编码格式
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.open
On Error Resume Next
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.charset = charset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
Private Sub Command1_Click()
URL = "http://www.qq.com"
Set xmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
xmlHttp.open "GET", Trim(URL), False
xmlHttp.send
text1.text=BytesToBstr(xmlHttp.responsebody, "UTF-8")
End Sub
'远程获取网页编码格式转换
Function BytesToBstr(body, charset) '转换成需要的编码格式
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.open
On Error Resume Next
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.charset = charset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询