ASPHttp使用范例-远程读取别人的页面,并自动写入库
2004-08-09 13:32
603 查看
<html>
<head>
<title>AUTOGET</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<%'on error resume next
'-----------建一个叫data的access表,字段(名称,来源,内容)
Set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("data.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath &";"
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from data"
rs.open sql,conn,3,2
'以上完成表的打开
Set HttpObj = Server.CreateObject("AspHTTP.Conn")
dim fd
fd = 111
SearchFolder fd
'以下是过程
Sub SearchFolder( fd )
do while fd <> 500
Response.Write fd
HTTPObj.Url = "http://www.object.net/Read.asp?ArticleID="&fd
HttpObj.RequestMethod = "GET"
content = HTTPObj.GetURL
'取标题<img
pos0=instr(1,content,"<img")
pos1=instr(pos0,content,">")
pos2=instr(pos1,content,"</td>")
title=mid(content,pos1+1,pos2-pos1-1)
'来源<td>
pos=instr(pos2,content,"<td>")
pos1=instr(pos,content,"</td>")
comefrom=mid(content,pos+4,pos1-pos-4)
'idno
pos1=instr(1,content,"ArticleID")
pos2=instr(pos1,content,">")
idno=mid (content,pos1+10,pos2-pos1-10)
'内容
pos1=instr(1,content,"<blockquote>")
pos2=instr(pos1,content,"</blockquote>")
content=mid (content,pos1+12,pos2-pos1-12)
'以下数据库操作:
rs.addnew
rs("名称")=title
rs("来源")=comefrom
rs("内容")=trim(content)
rs("idno")=trim(idno)
rs.update
fd=fd + 1
loop
end sub
'过程结束
Response.Write fd&"<br>"
rs.close
set conn=nothing
set fs=nothing
%>
</body>
</html>
<head>
<title>AUTOGET</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<%'on error resume next
'-----------建一个叫data的access表,字段(名称,来源,内容)
Set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("data.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath &";"
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from data"
rs.open sql,conn,3,2
'以上完成表的打开
Set HttpObj = Server.CreateObject("AspHTTP.Conn")
dim fd
fd = 111
SearchFolder fd
'以下是过程
Sub SearchFolder( fd )
do while fd <> 500
Response.Write fd
HTTPObj.Url = "http://www.object.net/Read.asp?ArticleID="&fd
HttpObj.RequestMethod = "GET"
content = HTTPObj.GetURL
'取标题<img
pos0=instr(1,content,"<img")
pos1=instr(pos0,content,">")
pos2=instr(pos1,content,"</td>")
title=mid(content,pos1+1,pos2-pos1-1)
'来源<td>
pos=instr(pos2,content,"<td>")
pos1=instr(pos,content,"</td>")
comefrom=mid(content,pos+4,pos1-pos-4)
'idno
pos1=instr(1,content,"ArticleID")
pos2=instr(pos1,content,">")
idno=mid (content,pos1+10,pos2-pos1-10)
'内容
pos1=instr(1,content,"<blockquote>")
pos2=instr(pos1,content,"</blockquote>")
content=mid (content,pos1+12,pos2-pos1-12)
'以下数据库操作:
rs.addnew
rs("名称")=title
rs("来源")=comefrom
rs("内容")=trim(content)
rs("idno")=trim(idno)
rs.update
fd=fd + 1
loop
end sub
'过程结束
Response.Write fd&"<br>"
rs.close
set conn=nothing
set fs=nothing
%>
</body>
</html>
相关文章推荐
- ASP.NET使用HttpWebRequest读取远程网页源代码
- ASP.NET使用HttpWebRequest读取远程网页源代码
- 使用WebClient自动填写并提交ASP.NET页面表单
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(5):服务器端和客户端数据类型的自动转换:基本类型和枚举类型
- 使用WebClient自动填写并提交ASP.NET页面表单 (zt)
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(8):服务器端和客户端数据类型的自动转换:数组类型
- 使用WebClient自动填写并提交ASP.NET页面表单
- ASP中使用XMLHTTP读取远程数据3
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(9):服务器端和客户端数据类型的自动转换:DataTable和DataSet
- asp.net中抓取远程页面,自动采集示例
- 使用WebClient自动填写并提交ASP.NET页面表单
- 使用WebClient自动填写并提交ASP.NET页面表单的源代码
- ASP中使用XMLHTTP读取远程数据1
- 使用WebClient自动填写并提交ASP.NET页面表单
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(9):服务器端和客户端数据类型的自动转换:DataTable和DataSet
- ASP中使用XMLHTTP读取远程数据3
- 使用WebClient自动填写并提交ASP.NET页面表单的源代码
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(10):服务器端和客户端数据类型的自动转换:以XML方式序列化数据、小结
- 使用HttpWebRequest以及HttpWebResponse读取Http远程文件
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(10):服务器端和客户端数据类型的自动转换:以XML方式序列化数据、小结