下面是一段ASP抓取程序 我在本地测试可以用 但是上传到虚拟主机就用不了 提示:msxml3.dll
错误 '800c0005'
系统未找到指定的资源。 /cheshiqu.asp,行 84 出错。
但是 我用:HTML 的网址测试就可以通过,,在本地和虚拟主机上都可以。。急求高手解决。收费也行
<%
Function getHTTPPage(urls)
dim objXML
set objXML=server.createobject("MICROSOFT.XMLHTTP")'定义
With objXML
.open "get",Urls,False
.setRequestHeader "Referer","index.php?class=CQSSC&act=list&id=834" '伪造referer
.Send
End With
On Error Resume Next
If objXML.Status<>200 then
Set objXML=Nothing
Exit function
End if
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
getHTTPPage=replace(getHTTPPage,"<","<")
'getHTTPPage=bytes2BSTR(objXML.responseBody)'或者返回信息时用函数转换汉字
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
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 = "UTF-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
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
Urls="index.php?class=CQSSC&act=list&id=834"
Html = getHTTPPage(Urls)
a="<h2>"
b="</h2>"
start=Newstring(Html,a)
over=Newstring(Html,b)
body=mid(Html,start,over-start)
c="正在开奖"
d="计划解说"
start=Newstring(Html,c)
over=Newstring(Html,d)
bodys=mid(Html,start,over-start)
response.write(body&bodys)
%> |