如果我输入浏览器(请参阅https://stackapps.com/questions/2/getting-started-with-the-api):
它返回
{
"statistics": [
{
"total_questions": 800830,
"total_unanswered": 131356,
"total_accepted": 500653,
"total_answers": 2158752,
"total_comments": 3125048,
"total_votes": 7601765,
"total_badges": 798091,
"total_users": 289282,
"questions_per_minute": 1.50,
"answers_per_minute": 3.12,
"badges_per_minute": 1.20,
"views_per_day": 455215.44,
"api_version": {
"version": "1.0",
"revision": "2010.7.17.1"
},
"site": {
"name": "Stack Overflow",
"logo_url": "http://sstatic.net/stackoverflow/img/logo.png",
"api_endpoint": "http://api.stackoverflow.com",
"site_url": "http://stackoverflow.com",
"description": "Q&A for professional and enthusiast programmers",
"icon_url": "http://sstatic.net/stackoverflow/apple-touch-icon.png",
"state": "normal",
"styling": {
"link_color": "#0077CC",
"tag_foreground_color": "#3E6D8E",
"tag_background_color": "#E0EAF1"
}
}
}
]
}
如果我在rebol控制台中输入:
read http://api.stackoverflow.com/1.0/stats
它返回一些奇怪的二进制字符。
答案 0 :(得分:3)
probe load to-string gunzip to-string read/binary http://api.stackoverflow.com/1.0/stats
connecting to: api.stackoverflow.com
{
"statistics": [
{
"total_questions": 801559,
"total_unanswered": 131473,
"total_accepted": 501129,
"total_answers": 2160171,
"total_comments": 3127759,
"total_votes": 7607247,
"total_badges": 798608,
"total_users": 289555,
"questions_per_minute": 0.93,
"answers_per_minute": 1.83,
"badges_per_minute": 0.73,
"views_per_day": 455579.60,
"api_version": {
"version": "1.0",
"revision": "2010.7.17.2"
},
"site": {
"name": "Stack Overflow",
"logo_url": "http://sstatic.net/stackoverflow/img/logo.png",
"api_endpoint": "http://api.stackoverflow.com",
"site_url": "http://stackoverflow.com",
"description": "Q&A for professional and enthusiast programmers",
"icon_url": "http://sstatic.net/stackoverflow/apple-touch-icon.png",
"state": "normal",
"styling": {
"link_color": "#0077CC",
"tag_foreground_color": "#3E6D8E",
"tag_background_color": "#E0EAF1"
}
}
}
]
}
答案 1 :(得分:2)
REBOL忽略了Content-Encoding: gzip
响应标头,无论您在Accept-Encoding:
标头中放置了什么,它都会坚持使用stackoverflow。在Unix上,wget和curl有同样的问题,但我可以这样做以查看预期的内容:
curl http://api.stackoverflow.com/1.0/stats | zcat
REBOL有办法解压缩gzip内容吗?
答案 2 :(得分:1)
基于http://www.mail-archive.com/rebol-bounce@rebol.com/msg03531.html
>> do http://www.rebol.org/download-a-script.r?script-name=gunzip.r
connecting to: www.rebol.org
Script: "gunzip" (30-Dec-2004)
>> print to-string gunzip read http://api.stackoverflow.com/1.0/stats
connecting to: api.stackoverflow.com
{
"statistics": [
{
"total_questions": 801316,
"total_unanswered": 131450,
"total_accept���������������������accept������E531450,
"tocomment312672�vote7605283badge7984187946531450,
tal_unans_per_minutet.0531450,
....
几乎可以工作:) 所以核心代码就在那里,只是没有正确曝光......真的很可惜......
但是stackoverflow既不是对http规范的抱怨也不是忽略了accept-encoding标头......