Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 打开URI不遵循重定向(不确定)_Ruby_Curl_Mechanize_Open Uri - Fatal编程技术网

Ruby 打开URI不遵循重定向(不确定)

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" 什么也没发生!我必须打断它

在这种情况下,我必须用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" 
什么也没发生!我必须打断它才能停下来。我很困惑,因为它在浏览器上运行得很好

但后来我试着卷曲,我得到:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/anna-university-grade-system-chennai.aspx?htno=211511104125&amp;AspxAutoDetectCookieSupport=1">here</a>.</h2>
</body></html>
对象已移动
对象移动到。
然后我尝试了
curl-L
,得到了文档

为什么会发生这种情况?我阅读了
openuri
自动跟踪重定向。
我该怎么做?

这可能是一个cookies问题。您是否尝试使用AspxAutoDetectCookieSupport=1的cookie文件发送请求?没有。我会努力的。顺便说一句,使用
mechanize
执行get操作很好。我将尝试使用cookie和open-uri。这似乎是一个html重定向,而不是
open-uri
支持的头重定向。啊,这增加了清晰度。为什么开放URI不支持它?我没有看到一个选项来启用它。