dim url,list_pagecode,array_articleid,i,articleid
dim content_pagecode,content_tempcode
dim content_categoryid,content_categoryname,borderid,classid,bordername,classname
dim articletitle,articleauthor,articlefrom,articlecontent
url = "http://www.webasp.net/article/class/1.htm"
list_pagecode = gethttppage(url)
list_pagecode = regexptext(list_pagecode,"打印</th></tr>","</table><table border=0 cellpadding=5",0)
list_pagecode = regexptext(list_pagecode,"<td align=left><a href="../",""><img border=0 src="../images/authortype0.gif"",1) "取得当前列表页的文章链接,以,分隔
array_articleid = split(list_pagecode,",") "创建数组,存储文章id
for i=0 to ubound(array_articleid)-1
articleid = array_articleid(i) "文章id
content_pagecode = gethttppage("http://www.webasp.net/article/"&articleid) "取得文章页的内容
"=========取文章分类及相关id参数 开始=======================
content_tempcode = regexptext(content_pagecode,"<a href=""/article/"">技术教程</a> >> ",">> 内容</td>",0)
content_categoryid = regexptext(content_pagecode,"<a href="../class","/">",1)
borderid = split(content_categoryid,",")(0) "大类id
classid = split(content_categoryid,",")(1) "子类id
"==========检查大类是否存在 开始===============
"如果不存在则入库
"==========检查大类是否存在 结束===============
"response.write(borderid & "," & classid & "<br />")
content_categoryname = regexptext(content_pagecode,"/">","</a>",1)
bordername = split(content_categoryname,",")(0) "大类名称
classname = split(content_categoryname,",")(1) "子类名称
"==========检查子类是否存在 开始===============
"如果不存在则入库
"==========检查子类是否存在 结束===============
"=========取文章分类及相关id参数 结束=======================
"=========取文章标题及内容 开始=============================
articletitle = regexptext(content_pagecode,"<tr><td align=center bgcolor=#dee2f5><strong>","</strong></td></tr>",0)
articleauthor = regexptext(content_pagecode,"<tr><td><span class=blue>作者:</span>","</td></tr>",0)
articlefrom = regexptext(content_pagecode,"<tr><td><span class=blue>来源:</span>","</td></tr>",0)
articlecontent = regexptext(content_pagecode,"<tr><td class=content style=""word-wrap: break-word"" id=zoom>","</td></tr>"&vbcrlf&" </table>"&vbcrlf&" </td></tr></table>",0)
"=========取文章标题及内容 结束=============================
response.write(articletitle& "<br /><br />")
response.flush()
next
附几个函数:
function gethttppage(url)
if(isobjinstalled("microsoft.xmlhttp") = false)then
response.write "<br><br>服务器不支持microsoft.xmlhttp组件"
err.clear
response.end
end if
on error resume next
dim http
set http=server.createobject("msxml2.xmlhttp")
http.open "get",url,false
http.send()
if(http.readystate<>4)then
exit function
end if
gethttppage=bytestobstr(http.responsebody,"gb2312")
set http=nothing
if(err.number<>0)then
response.write "<br><br>获取文件内容出错"
"response.end
err.clear
end if
end function
function bytestobstr(codebody,codeset)
dim objstream
set objstream = server.createobject("adodb.stream")
objstream.type = 1
objstream.mode =3
objstream.open
objstream.write codebody
objstream.position = 0
objstream.type = 2
objstream.charset = codeset
bytestobstr = objstream.readtext
objstream.close
set objstream = nothing
end function^^^^^6
高端网站建设价格套餐:
500元成品模板网站套餐1000元基础型网站套餐1800元标准定制设计套餐2800元精美定制设计套餐3800-8000元商务型套餐行业门户型套餐其它定制套餐 文章由重庆一佰互联高端网站建设http://www.rzxsoft.cn编辑整理,转载请注明出处