当前位置:编程学习 > asp >>

ASP抓取网页内容的代码

答案:

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,"“)
  
   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)

上一个:ASP关于SELECT的无限级联
下一个:省略dim,方便但也是隐患

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,