VB如何提取网页框架源码(不用WebBrowser和inst控件)
如题,vb中不使用WebBrowser和inst控件如何提取网页框架源码?用XMLHTTP实现。满意后百分相送!...
如题,vb中不使用WebBrowser和inst控件如何提取网页框架源码?
用XMLHTTP实现。
满意后百分相送! 展开
用XMLHTTP实现。
满意后百分相送! 展开
1个回答
展开全部
Function getHTTPPage(url)
' On Error Resume Next
Dim http
Set http = CreateObject("Microsoft.XMLHTTP")
http.Open "GET", url, False
http.send (Null)
If http.readystate <> 4 Then
Exit Function
End If
getHTTPPage = BytesToBstr(http.responseBody, "GB2312")
Set http = Nothing
If Err.Number <> 0 Then
getHTTPPage = "服务器获取文件内容出错"
Err.Clear
End If
End Function
Function BytesToBstr(body, Cset)
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
Private Sub Command1_Click()
url = "http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml"
Dim str: str = getHTTPPage(url)
Text1.Text = str
End Sub
' On Error Resume Next
Dim http
Set http = CreateObject("Microsoft.XMLHTTP")
http.Open "GET", url, False
http.send (Null)
If http.readystate <> 4 Then
Exit Function
End If
getHTTPPage = BytesToBstr(http.responseBody, "GB2312")
Set http = Nothing
If Err.Number <> 0 Then
getHTTPPage = "服务器获取文件内容出错"
Err.Clear
End If
End Function
Function BytesToBstr(body, Cset)
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
Private Sub Command1_Click()
url = "http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml"
Dim str: str = getHTTPPage(url)
Text1.Text = str
End Sub
更多追问追答
追问
谢谢,这个是网页源码,我想提取网页框架源码
view-source:http://d1.sina.com.cn/iframe/5/2008/0703/4.html这个。
如果你是360浏览器,你右击搜索那边,有一项是查看框架源码。
要里面的框架源码- -
追答
你人为能得到框架源码吗?把贴出来看看,我没有找到
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询