OpenURI - XML 源上的 500 内部服务器错误
我正在尝试阅读斯坦福 ecorner XML:
open("http://ecorner.stanford.edu/RecentlyAdded.xml")
但遇到以下错误消息:
OpenURI::HTTPError: 500 Internal Server Error
from /usr/local/lib/ruby/1.8/open-uri.rb:277:in `open_http'
from /usr/local/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
from /usr/local/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:162:in `catch'
from /usr/local/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
from /usr/local/lib/ruby/1.8/open-uri.rb:518:in `open'
from /usr/local/lib/ruby/1.8/open-uri.rb:30:in `open'
from (irb):65
from :0
我相信,但我可能是错的,这是因为我需要登录才能使用提要。
我可以使用任何解决方法吗?
I'm trying to read Stanford ecorner XML:
open("http://ecorner.stanford.edu/RecentlyAdded.xml")
but am running into the following error message:
OpenURI::HTTPError: 500 Internal Server Error
from /usr/local/lib/ruby/1.8/open-uri.rb:277:in `open_http'
from /usr/local/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
from /usr/local/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:162:in `catch'
from /usr/local/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
from /usr/local/lib/ruby/1.8/open-uri.rb:518:in `open'
from /usr/local/lib/ruby/1.8/open-uri.rb:30:in `open'
from (irb):65
from :0
I believe, but I could be wrong, it's because I would need to be logged in to use the feed.
Any workaround I could use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果未登录,您应该收到 HTTP 响应代码
401 Unauthorized
而不是500
。我尝试在浏览器中打开该网站,结果有效。事实证明,他们的网络服务器不喜欢缺少用户代理,因此如果您添加open-uri
即可:In case of not being logged in you should get an HTTP response code of
401 Unauthorized
and not500
. I tried to open the site in the browser, which works. Turns out their web server doesn't like missing user agents, so if you add thatopen-uri
works:这对我有用:
请注意,您遇到了 500 范围的错误。这意味着他们的服务器正在运行,但功能足以承认该问题。如果您收到 400 范围的错误,他们会出于某种原因拒绝您访问内容,所以我怀疑问题出在身份验证或您这边的任何问题上。
This is working for me:
Note that you got a 500-range error. That means their server is acting up, but is functional enough to admit the problem. If you got a 400-range error they'd be refusing you access to the content for some reason, so I doubt the problem is authentication or anything on your side.