never-online 's Tech Blog In CSDN

never online - Everlasting love for angela.

用户操作
[即时聊天] [发私信] [加为好友]
never-onlineID:BlueDestiny
153975次访问,排名502好友17人,关注者33
在京城
BlueDestiny的文章
原创 114 篇
翻译 0 篇
转载 8 篇
评论 224 篇
never-online的公告
Web:
www.never-online.net
Email:
BlueDestiny##126.com
QQ:
77091373
最近评论
kwlong2008:来看看朋友,最近过的怎么样?俺的空间是介绍网站制作网站建设的,有时间也常去一下我的空间谢谢,wow gold

When you play a game of the day, the list of friends in the game whether there are always a few names of black
wow power leveling<……
zyhomepage:支持一下
clicksun:如果要制作纯CSS+DIV的圆角方框图形,可以到这里直接在线制作,什么颜色都可以:http://corner.cha.la
C_SuperMe:可以好好学习一下啊!!
文章分类
收藏
相册
icon
JS & DHTML
Dhteumeuleu
Douglas Crockford
Webfx
常去之地
ASP.Net
MSDN英文
XML指南
XML的大本营
博客园
正则表达式
我的网站
我网站的Blog(RSS)
友情链接
KimSoft的blog(RSS)
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 asp 利用 xmlhttp 抓取网页内容收藏

新一篇: 关于Xhtml+CSS的web标准 | 旧一篇: IIS6.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/"
        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>

发表于 @ 2004年10月27日 16:54:00|评论(loading...)|编辑

新一篇: 关于Xhtml+CSS的web标准 | 旧一篇: IIS6.0服务器架站无法访问解决方案总结

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © never-online