當前位置:編程學習大全網 - 源碼下載 - VB 如何提取網頁源帶碼的所有url鏈接

VB 如何提取網頁源帶碼的所有url鏈接

VB6新建壹個工程加入以下源碼(不加任何控件)

Dim Label() As Object

Dim clsT() As New Class1

Function getHTTPPage(Url)

Dim Http

Set Http = CreateObject("MSXML2.XMLHTTP")

Http.Open "GET", Url, False

a = Http.send()

If Http.readystate <> 4 Then

Exit Function

End If

getHTTPPage = BytesToBstr(Http.responseBody, "GB2312")

Set Http = Nothing

If Err.Number <> 0 Then Err.Clear

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 Form_Load()

Dim Url, Html

Url = InputBox("請輸入壹個網址")

a = Split(getHTTPPage(Url), "href=")

Dim i As Integer

Dim nTop As Long

ReDim Label(UBound(a) - 1)

ReDim clsT(UBound(a) - 1)

For i = 1 To UBound(a) - 1

Set Label(i) = Controls.Add("VB.Label", "Label" & CStr(i))

Label(i).Height = 300

Label(i).Top = nTop

Label(i).Visible = True

TEMP = Split(a(i), ">")(0)

If Left(TEMP, 4) <> " Explorer\iexplore.exe " & L.Caption

End Sub

  • 上一篇:pentaho bi在 myeclipse中怎麽部署
  • 下一篇:昆侖山是人們傳說中的神仙居住的地方,有具體說法嗎?
  • copyright 2024編程學習大全網