asp采集js文件的代码
发布网友
发布时间:2022-07-27 04:43
我来回答
共1个回答
热心网友
时间:2023-10-24 20:15
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修改一下即可。追问不是整个文件,而是部分内容