怎么用asp程序读取url再用程序读取出结果,求完整asp程序
------解决方案--------------------
原来不是发过了?知识变成数组了而且,方法都差不多
<script runat=server language=jscript>
function getjson(v) { return eval('(' + v + ')'); }
function toarray(a) {//json对象数组格式的字符串
var dic = server.createobject(scripting.dictionary);
for (var i = 0; i < a.length; i++) {
var obj = server.createobject(scripting.dictionary);
for (x in a[i]) obj.add(x, a[i][x]);
dic.add(i, obj);
}
return dic;
}
</script>
<%
'==================================================
'从2进制数据流生成内容
'==================================================
function bytestobstr(strbody,codebase)
dim obj
set obj=server.createobject(adodb.stream)
obj.type=1
obj.mode=3
obj.open
obj.write strbody
obj.position=0
obj.type=2
obj.charset=codebase
bytestobstr=obj.readtext
obj.close
set obj=nothing
end function
function downpage(url)
set xhr=server.createobject(microsoft.xmlhttp)
xhr.open get,url,false
xhr.send
downpage=bytestobstr(xhr.responsebody,gb2312)'注意你那个页面的编码,要不可能出乱码
end function
's改为用microsoft.xmlhttp动态获取
's=downpage()
s={resultcode:200,reason:return successd,result:[{id:1,province:陕西省,city:西安市,area:灞桥区,address:狄寨镇南寨村},{id:2,province:陕西省,city:西安市,area:灞桥区,address:狄寨镇潘村}
,{id:3,province:陕西省,city:西安市,area:灞桥区,address:狄寨镇伍坊村}],error_code:0}
set o=getjson(s)
if o.resultcode=200 then
set result=toarray(o.result)
for i=0 to result.count-1
response.write result(i)(province)&-&result(i)(address)&<br/>
next
set result=nothing
end if
set o=nothing
%>
中国足彩网信息请查看IT技术专栏
2025国考·省考课程试听报名