Caught the code for web page extraction web content

xiaoxiao2021-03-06  41

DIM SURL

SURL = "http://travel.state.gov/visa/frvi_bulletincurrent.html"

Function streamtochar (Strstream)

Set stream = creteObject ("adodb.stream")

Stream.Type = 1

Stream.mode = 3

Stream.open

Stream.write strStream

Stream.position = 0

Stream.type = 2

Stream.Charset = "GB2312"

Streamtochar = stream.readtext

Stream.Close

Set stream = Nothing

End Function

I = i 1

Function GetContentByURL (URL)

SET XMLHTTP = CREATEOBJECT ("msxml2.xmlhttp")

XMLHTTP.Open "GET", URL, FALSE

XMLHTTP.SEND

GetContentByurl = streamtochar (Oxmlhttp.Responsebody)

SET XMLHTTP = Nothing

End Function

 

Function GetRealContent (URL)

Scontent = GetContentByURL (URL)

GetRealContent = SCONTENT

End Function

 

  ahtml = getContentByurl (surl)

URL_START = INSTR (HTML, ")

DATE_START = INSTR (HTML, "Washington, D.c.") 57 DATE_END = INSTR (HTML, "A. STATUTORY") - 14  DATE_T = MID (HTML, DATE_START, DATE_END-DATE_START)

URL_END = INSTR (HTML, ")   URL = MID (HTML, URL_START, URL_END-URL_START)   URL = Replace (URL," ")

转载请注明原文地址:https://www.9cbs.com/read-77924.html

New Post(0)