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
Python 由于http 405错误,使用POST从网站自动检索数据不起作用_Python_Ruby_Perl_Http Post_Bots - Fatal编程技术网

Python 由于http 405错误,使用POST从网站自动检索数据不起作用

Python 由于http 405错误,使用POST从网站自动检索数据不起作用,python,ruby,perl,http-post,bots,Python,Ruby,Perl,Http Post,Bots,我正在进行类似的工作,以自动化一个脚本,从结果网站获取数据(提交卷号并获得结果) 我在这里使用Ruby,并使用POST方法提交卷号并获得结果页面,但是由于接受卷号的主要目标页面是一个.htm页面,因此我最终得到了一个 HTTP Status 405 - Request method 'POST' not supported (此问题的大多数解决方案都建议在服务器端进行更新,而这不在我的控制范围内)我希望自动化并获得结果,以便为数据挖掘目的创建数据集 我试图研究如何使用自动脚本获得结果页面,但没

我正在进行类似的工作,以自动化一个脚本,从结果网站获取数据(提交卷号并获得结果)

我在这里使用Ruby,并使用POST方法提交卷号并获得结果页面,但是由于接受卷号的主要目标页面是一个.htm页面,因此我最终得到了一个

HTTP Status 405 - Request method 'POST' not supported
(此问题的大多数解决方案都建议在服务器端进行更新,而这不在我的控制范围内)我希望自动化并获得结果,以便为数据挖掘目的创建数据集

我试图研究如何使用自动脚本获得结果页面,但没有得到任何令人满意的结果。有人能让我知道如何通过任何脚本实现它吗?语言对我来说并不重要,因为数据收集是目标

实现这一目标的任何指导都会有所帮助

我试图从网站上提取2007年的结果

http://resultsarchives.nic.in/cbseresults/cbseresults2007/aieee/cbseaieee.htm
您可以使用样本卷编号系列2480000。。24809999,假设24801002是有效的卷号(8位),以查看结果如何显示


我用不同的语言对问题进行了标记,因为我觉得这些语言中的任何一种都可能存在解决方案。

如果您检查浏览器在使用该网站时发出的请求,您将看到POST请求发送到:

http://resultsarchives.nic.in/cbseresults/cbseresults2007/aieee/cbseaieee.asp
有了这些数据:

regno: 24801002

您可以将此URL作为目标来抓取网站(如果允许)。

据我所知,该网站的“不禁止编程访问”,因此我认为您可以接受

使用Perl模块是一项非常简单的工作

看起来是这样的。请注意,输出只是HTML页面的文本内容,因此没有换行符。如果您想要HTML本身,请使用
$mech->content
而不是
$mech->text

use strict;
use warnings;

use WWW::Mechanize;

my $url = 'http://resultsarchives.nic.in/cbseresults/cbseresults2007/aieee/cbseaieee.htm';

my $mech = WWW::Mechanize->new;

$mech->get($url);

$mech->submit_form( fields => { regno => 24809999 } );
print $mech->text, "\n";
输出

 CBSE - ALL INDIA ENGINEERING / ARCHITECTURE ENTRANCE EXAMINATION 2007 http://cbseresults.nic.in      Examination Results 2007      Brought to you by National Informatics Centre    ALL INDIA ENGINEERING / ARCHITECTURE ENTRANCE EXAMINATION (AIEEE - 2007) Roll No: 24809999 Name: BHOSALE CHETAN ANIL Mother's Name: BHOSALE UJJVALA ANIL Father's Name: BHOSALE ANIL BHAGWANRAO Paper    Subjects    Marks ObtainedPaper-1 Physics, Chemistry & Mathematics -2 Paper-2 Mathematics & Aptitude Test Not Applicable/Not Applied   B.E./B.Tech  B.Arch All India Rank 539404 ------ State Rank( State code of eligibility : 21  ) 41736 ------  Remarks:  BTECH:   - Not Eligible for Central CounsellingBARCH:   -   Note:  For details on central counselling, Please visit http://ccb.nic.in or http://aieee.nic.in Cut off score for the purpose of counselling has been decided by Central Counselling Board.  State Ranks are based on State Code of Eligibility ie. State from where the candidate has passsed +2 examination. Those who have not filled up State Code of eligibility, their State rank has not been indicated. State rank is privisional subject to verification of documents at the time of counselling.  Disclaimer: Neither NIC nor CBSE is responsible for any inadvertent error that may have crept in the results being published on NET. The results published on net are for immediate information to the examinees. These cannot be treated as original Score card. Original Score cards shall be despatched by the Board.   Designed, Developed and Hosted by National Informatics Centre 

这是不允许的,如果我使用post方法将.asp链接作为目标,它会发送拒绝访问的页面:(,还有其他方法吗?谢谢,它工作得很好:):),这将有助于我为数据挖掘项目收集数据。