导航:业界 | 认证 | 工具 | 图形 | 技术 | 系统 | 网络 | 办公 | 网页 | 文摘 | 动画
您当前的位置:diva8.com -> I T -> 技术 -> ASP学院 -> I T内容
栏目导航
· .Net专栏 · Script
· ASP学院 · PHP学院
· Web服务器 · CGI学院
· XML学院 · SQL学院
· JSP学院 · SMS学院
热门I T
· [组图] 音频后期处理Adobe ...
· [组图] Photoshop--照片处理...
· [组图] 廉颇老矣?IE7.0 Bet...
· [图文] DuDu下载加速器推出...
· [组图] 清晰还原!Photoshop...
· [组图] 用photoshop给图片祛...
· [组图] DuDu 下载加速器试用...
· [组图] 新春特别版:PPLIVE...
· [图文] 让查找更方便些 腾讯...
· [组图] 廉颇老矣?IE7.0 Bet...
相关I T
· [组图] 网页内容转Word表格...
· 用Word保存网页内容...
· 网页制作 JSP与ASP ...
· 网页内容截取组件V1...
· [图文] CSDN 总结 精华 ASP...
· [组图] 浅谈网页内容之动态...
· [组图] 网页内容浏览任意伸...
· ASP 语言阶段教程
· 跨站ASP Script攻击...
· 温柔的杀手—跨站AS...
asp 利用 xmlhttp 抓取网页内容
作者:Admin  来源:齐昌网络  发布时间:2004-11-2 15:36:08  发布人:qichang

减小字体 增大字体



抓取网页。偶要实现实实更新天气预报。利用了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>
(出处:Viphot)


[] [返回上一页] [打 印] [收 藏]
下一篇I T:脚本语言的应用
∷相关I T评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 在线人数:
diva8.com Copyright © 2001-2006 diva8.com All Rights Reserved .粤ICP备05014750号