当前位置:首页 > 代码 > 正文

asp采集代码(asp代码调试)

admin 发布:2022-12-19 11:59 105


本篇文章给大家谈谈asp采集代码,以及asp代码调试对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

ASP采集程序中添加代码!!!

Const ok22_count= 0 '初始人气

把上面这行改为以下三行:

Dim ok22_count

Randomize

ok22_count = Int((9999 - 1000 + 1) * Rnd + 1000)

这样,生成的随机数从1000到9999

ASP批量采集代码

Dim strurl

strurl = Getarrayurl(Request("dname"))

Function Getarrayurl(str) '====采集的域名串处理

If str = "" Then exit Function

str_ = Replace(str,chr(13),",")

str_ = Replace(str_,chr(10),"")

str_ = Replace(str_," ","")

Getarrayurl = str_

End function

If strurl "" Then Call CmfeiShow()

Sub CmfeiShow()

strurl_ = split(strurl,",")

For i=0 to Ubound(strurl_)

If i2 Then Exit For '===最多采集的网页个数

If left(strurl_(i),7)="http://" Then

strShow = GetKey(getHTTPPage(strurl_(i)),"h1","/h1")

Response.Write strShow "br/"

End If

Next

End Sub

例子:本例子只采集最靠前的三个网页的title标签的内容。。

asp采集js文件的代码

caiurl是采集源网址,pcontent=bytestobstr(getbody(caiurl),"gb2312") 是采集调用代码,如果采集的目标页面是utf-8格式的,请把gb2312修改成utf-8,即pcontent=bytestobstr(getbody(caiurl),"utf-8")

%

response.charset="gb2312"

response.expires = -9999

response.addheader "pragma","no-cache"

response.addheader "cache-ctrol","no-cache"

caiurl="网址/qqlogin.js"

function getbody(weburl)

dim objxmlhttp

set objxmlhttp=server.createobject("msxml2.serverxmlhttp")

'如果服务器不支持msxml2.serverxmlhttp,可以修改成msxml3.serverxmlhttp或msxml6.serverxmlhttp或msxml2.xmlhttp

objxmlhttp.open "get",weburl,false

objxmlhttp.send

while objxmlhttp.readystate 4

objxmlhttp.waitforresponse 10000

wend

getbody=objxmlhttp.responsebody

set objxmlhttp=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

pcontent=bytestobstr(getbody(caiurl),"gb2312")

response.write(pcontent)

%

这样就可以把 网址/qqlogin.js 这个js文件采集到了,并存在pcontent变量中,如果要加入自己的代码,再把pcontent修改一下即可。

ASP采集代码,请举出例子

%

'功能:asp采集代码

url=""

str=getHTTPPage(url)

title=strcut(str,"h1 id=""h1title""","/h1",2)

content=strcut(str,"手机看新闻/a/span","(本文来源",2)

response.write "新闻标题brb"title"/bbrbrbr新闻内容:br"content

'获取当前网址的源代码

Function getHTTPPage(url)

On Error Resume Next

dim http

set http=Server.createobject("Microsoft.XMLHTTP")

Http.open "GET",url,false

Http.send()

if Http.readystate4 then

exit function

end if

getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

set http=nothing

If Err.number0 then

Response.Write "p align='center'font color='red'b服务器获取文件内容出错/b/font/p"

Err.Clear

End If

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

'截取字符串,1.包括起始和终止字符,2.不包括

Function strCut(strContent,StartStr,EndStr,CutType)

Dim strHtml,S1,S2

strHtml = strContent

On Error Resume Next

Select Case CutType

Case 1

S1 = InStr(strHtml,StartStr)

S2 = InStr(S1,strHtml,EndStr)+Len(EndStr)

Case 2

S1 = InStr(strHtml,StartStr)+Len(StartStr)

S2 = InStr(S1,strHtml,EndStr)

End Select

If Err Then

strCute = "p align='center'没有找到需要的内容。/p"

Err.Clear

Exit Function

Else

strCut = Mid(strHtml,S1,S2-S1)

End If

End Function

%

asp采集代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于asp代码调试、asp采集代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/7762.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载