选择显示字体大小

asp 利用 xmlhttp 抓取网页内容

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


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons