Ruby 打开URI不遵循重定向(不确定)
在这种情况下,我必须用ruby阅读此url:Ruby 打开URI不遵循重定向(不确定),ruby,curl,mechanize,open-uri,Ruby,Curl,Mechanize,Open Uri,在这种情况下,我必须用ruby阅读此url: http://tamilnadu.schools9.com/anna-university-grade-system-chennai.aspx?htno=211511104125 现在,当我 require 'open-uri' open "http://tamilnadu.schools9.com/anna-university-grade-system-chennai.aspx?htno=211511104125" 什么也没发生!我必须打断它
http://tamilnadu.schools9.com/anna-university-grade-system-chennai.aspx?htno=211511104125
现在,当我
require 'open-uri'
open "http://tamilnadu.schools9.com/anna-university-grade-system-chennai.aspx?htno=211511104125"
什么也没发生!我必须打断它才能停下来。我很困惑,因为它在浏览器上运行得很好
但后来我试着卷曲,我得到:
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/anna-university-grade-system-chennai.aspx?htno=211511104125&AspxAutoDetectCookieSupport=1">here</a>.</h2>
</body></html>
对象已移动
对象移动到。
然后我尝试了curl-L
,得到了文档
为什么会发生这种情况?我阅读了openuri
自动跟踪重定向。
我该怎么做?这可能是一个cookies问题。您是否尝试使用AspxAutoDetectCookieSupport=1的cookie文件发送请求?没有。我会努力的。顺便说一句,使用
mechanize
执行get操作很好。我将尝试使用cookie和open-uri。这似乎是一个html重定向,而不是open-uri
支持的头重定向。啊,这增加了清晰度。为什么开放URI不支持它?我没有看到一个选项来启用它。