您的位置:首页 > 编程语言

抓取网页萃取网页内容的代码 选择自 liujien 的 Blog

2006-05-15 21:46 393 查看
dim sUrl
 sUrl="http://travel.state.gov/visa/frvi_bulletincurrent.html"
 Function streamtochar(StrStream)
 set stream=CreateObject("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

html= getContentByUrl(surl)
 url_start=inStr(html," " )
 url_end=inStr(html," ")
 url=Mid(html,url_start,url_end-url_start)
 url=replace(url,"“)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: