MSXML2.ServerXMLHTTP 取返回页面值的奇怪的问题?

ycwww 2017-05-12 11:29:34
求asp 获取这个 新浪 短网址 的源码:
http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=http://www.163.com

经过测试
用 Gethttppage(“http://www.163.com”) 取值正常
但是用 Gethttppage("http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=http://www.163.com")
没有返回值。

但是新浪的这个网址直接打开到浏览器又能正常显示数据。

==== 之前一直正常使用的,今天发现获取不到了,用到的函数如下 ====

function Gethttppage(url)
on error resume next
dim adxmlhttp
set adxmlhttp = Server.createobject("MSXML2.ServerXMLHTTP")
adxmlhttp.open "get",url,false
On Error Resume Next
adxmlhttp.send()
if (adxmlhttp.readystate <> 4) Or (adxmlhttp.Status <> 200) then exit function
gethttppage = Bytes2bStr(adxmlhttp.responsebody)
set adxmlhttp = nothing
End function

function Bytes2bStr(vin)
on error resume next
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject("adodb.stream")
BytesStream.Type = 2
BytesStream.Open
BytesStream.WriteText vin
BytesStream.Position = 0
BytesStream.Charset = "gb2312"
BytesStream.Position = 2
StringReturn =BytesStream.ReadText
BytesStream.close
Set BytesStream = Nothing
Bytes2bStr = StringReturn
End function
...全文
224 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ycwww 2017-05-13
  • 打赏
  • 举报
回复
谢谢,换了个服务器就可以了,应该是组件问题。
hookee 2017-05-13
  • 打赏
  • 举报
回复
Bytes2bStr字符集改成UTF-8的试试看 新浪的响应头是 Content-Type application/json;charset=UTF-8

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧