欢迎光临
我们一直在努力

xmlhttp 抓取网页内容1-ASP教程,XML相关

建站超值云服务器,限时71元/月

<%

on error resume next

server.scripttimeout=9999999

function gethttppage(path)

t = getbody(path)

gethttppage=bytestobstr(t,"gb2312")

end function

function bytes2bstr(vin)

strreturn = ""

for j = 1 to lenb(vin)

thischarcode = ascb(midb(vin,j,1))

if thischarcode < &h80 then

strreturn = strreturn & chr(thischarcode)

else

nextcharcode = ascb(midb(vin,j+1,1))

strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))

j = j + 1

end if

next

bytes2bstr = strreturn

end function

function getbody(url)

on error resume next

set retrieval = createobject("microsoft.xmlhttp")

retrieval.open "get", url, false, "", ""

retrieval.send

getbody =retrieval.responsebody

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

function newstring(wstr,strng)

newstring=instr(lcase(wstr),lcase(strng))

if newstring<=0 then newstring=len(wstr)

end function

%>

<%

dim wstr,str,url,start,over,city

city = request.querystring("id")

url="http://cn.finance.yahoo.com/q?s=usdkrw=x&d=c"

wstr=gethttppage(url)

start=newstring(wstr,"最後交易")

over=newstring(wstr,"买方出价")

body=mid(wstr,start,over-start)

start2=instr(body,"<b>")+3

over2=instr(body,"</b>")

body2=mid(body,start2,over2-start2)

response.write body2

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » xmlhttp 抓取网页内容1-ASP教程,XML相关
分享到: 更多 (0)

相关推荐

  • 暂无文章