用MSXML2.XMLHTTP提取网页源码后不知道如何才能一行行分析源码
用了一个笨方法
Private Sub tiqu(ByVal url As String) Dim Retrieval Retrieval = CreateObject("MSXML2.XMLHTTP") With Retrieval .Open("Get", url, False) ', "", "" .Send() My.Computer.FileSystem.WriteAllBytes("c:\abc.htm", .ResponseBody, False) End With Retrieval = Nothing End Sub
'获取网页源码Public Function GetBody(priStrUrl As String, priStrMothed As String) As String Dim HtmlCode As String = "" Try Retrieval.open(priStrMothed, priStrUrl, False, "", "") Retrieval.send(Nothing) Dim b As [Byte]() = DirectCast(Retrieval.responseBody, [Byte]()) HtmlCode = System.Text.ASCIIEncoding.GetEncoding("gb2312").GetString(b, 0, b.Length) Retrieval.abort() Catch e As Exception e.ToString() Return "error" End Try Return HtmlCodeEnd Function