asp中利用xmlhttp抓取网页内容的代码
来源:asp之家 发布时间:2023-07-06 04:18:12
需要分件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.aspxhome.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>
猜你喜欢
- 前言其实Python 的列表(list)内部实现是一个数组,也就是一个线性表。在列表中查找元素可以使用 list.index() 方法,其时
- window.opener.location.reload()刷新父窗口window.opener.location.reload() 与
- 一、匿名块和命名块◆PL/SQL块分为良好总:命名块和匿名块。◆匿名块:以declare或begin开始,每次执行匿名块都要通过客户端工具将
- 先来聊一聊Top K算法,具体内容如下应用场景: 搜索引
- Vue 的用法没有变化:<template lang="pug"> transition(name=&quo
- 本节重点掌握Cpython的GIL解释器锁的工作机制掌握GIL与互斥锁掌握Cpython下多线程与多进程各自的应用场景本节时长需控制在45分
- 文件目录层级一、文件读取的绝对路径和相对路径用相对路径和绝对路径读取上一层目录的文件、下一层目录的文件及读取同层级的文件。# @File :
- 本文实例讲述了Python爬虫框架scrapy实现的文件下载功能。分享给大家供大家参考,具体如下:我们在写普通脚本的时候,从一个网站拿到一个
- 1.概述python中的日志库logging使用起来有点像log4j,但配置通常比较复杂,构建日志服务器时也不是方便。标准库logging的
- 一、数组和切片的区别是什么?1.数组数组是内置(build-in)类型,是一组同类型数据的集合,它是值类型,通过从0开始的下标索引访问元素值
- 1.mysql中or语法的使用,在mysql语法中or使用注意点。 项目遇到坑,遍历发放奖励数据查询错误!!!$sql = 'SEL
- 一、打开/关闭文件1、对文件操作时首先要打开文件,打开文件用 fopen()函数,语法是:fopen(filename,mode,inclu
- flatten()函数用法flatten是numpy.ndarray.flatten的一个函数,即返回一个一维数组。flatten只能适用于
- (1)序列化即js中的Object转化为字符串1.使用obj.toJSONString()var str=obj.toJSONString(
- 解释机器学习模型是一个困难的过程,因为通常大多数模型都是一个黑匣子,我们不知道模型内部发生了什么。创建不同类型的可视化有助于理解模型是如何执
- jupyter notebookjupyter不被识别为内部或外部命令,可操作程序或批处理文件'上次 jupyter noteboo
- 导言在前面一些教程中,我们已经看到如何使用应用程序框架,ObjectDataSource,以及那些提供增、改、删功能的数据Web控件。在我们
- 在开发过程中我们需要将我们的数据通过图标的形式展现出来,接下来我为大家介绍一个有趣的框架:Echarts。这是一个使用JavaScript实
- 详解Python MD5加密Python 3下MD5加密# 由于MD5模块在python3中被移除# 在python3中使用hashlib模
- 前言:把一个功能模块使用组件化的思想充分封装,如导航栏,这无论对我们的开发思想还是效率都有许多好处,在开发中,我们要尽量多得运用组件化的开发