• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

asp 利用 xmlhttp 抓取网页内容_jquery

jquery 搞代码 7年前 (2018-06-12) 111次浏览 已收录 0个评论

xmlhttp抓取网页,最近在博客园里看到了这篇文章,于是就顺便贴到blog上,
原url:http://www.cnblogs.com/hover/archive/2004/10/09/36212.aspx     (博客园-翱翔.Net Blog)

抓取网页。偶要实现实实更新天气预报。利用了XMLHTTP组件,抓取网页的指定部分。
需要分件html源代码
此例中的被抓取的html源代码如下
<p align=left>2004年8月24日星期二;白天:晴有时多云南风3―4级;夜间:晴南风3―4级;气温:最高29℃最低19℃ </p>
而程序中是从
以2004年8月24日为关键字搜索,直到</p>结速
而抓取的内容就变成了”2004年8月24日星期二;白天:晴有时多云南风3―4级;夜间:晴南风3―4级;气温:最高29℃最低19℃ “
干干净净的了。记录一下。

 

<%
On Error Resume Next
Server.ScriptTimeOut=9999999
Function getHTTPPage(Path)
        t = GetBody(Path)
        getHTTPPage=BytesToBstr(t,”GB2312″)
End function

Function GetBody(url)
        on error resume next
        Set Retrieval = CreateObject(“Microsoft.XMLHTTP”)
        With Retrieval
        .Open “Get”, url, False, “”, “”
        .Send
        GetBody = .ResponseBody
        End With
        Set Retrieval = Nothing
End Function

Function BytesToBstr(body,Cset)
        dim objstream
        set objstream = Server.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
Function Newstring(wstr,strng)
        Newstring=Instr(lcase(wstr),lcase(strng))
        if Newstring<=0 then Newstring=Len(wstr)
End Function
%>

<html>

<BODY bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT=0 MARGINWIDTH=0>
<!– 开始 –>   

<%
Dim wstr,str,url,start,over,dtime
dtime=Year(Date)&”年”&Month(Date)&”月”&Day(Date)&”日”
url=”http://www.qianhuaweb.com/&#8221;
        wstr=getHTTPPage(url)
        start=Newstring(wstr,dtime)
        over=Newstring(wstr,”</p>”)
 body=mid(wstr,start,over-start)

response.write “<MARQUEE onmouseover=this.stop(); onmouseout=this.start();>”&body&”</marquee>”

%>
<!– 结束 –>
</body></html>

 

欢迎大家阅读《asp 利用 xmlhttp 抓取网页内容_jquery,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:asp 利用 xmlhttp 抓取网页内容_jquery

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址