【问题标题】:How do I scrape my collage result website如何抓取我的大学成绩网站
【发布时间】:2020-01-31 09:36:54
【问题描述】:

我想从我的拼贴结果网站收集学生的结果数据 - http://www.bietjhs.ac.in/result2019/GetResult.aspx

为此,我使用了 python 中的 requests 模块

import requests
from bs4 import BeautifulSoup
url = 'http://www.bietjhs.ac.in/result2019/Result.aspx'

values = {'__VIEWSTATE':'/wEPDwULLTEwMTgxNzc0MDlkZPl3fGYoB3mixdEklq4qolYFT0kX',
          '__VIEWSTATEGENERATOR':'83531E22',
          '__EVENTVALIDATION':'/wEWAwL1j+SrAgK097CQBgLCi9reAwX5Exu+9wGq1/SB++dfh19a1B4s',
          'txtRollNo':'1804310063'}


respond = requests.post(url = url,data = values)

soup = BeautifulSoup(respond.content,features='html.parser')

print(soup.text)

我的代码解释成功,但网站响应运行时错误。

运行时错误

\'/result2019\' 应用程序中的服务器错误。

运行时错误

说明:服务器上出现应用程序错误。此应用程序的当前自定义错误设置阻止远程查看应用程序错误的详细信息(出于安全原因)。但是,它可以被本地服务器机器上运行的浏览器查看。

详细信息:启用此特定错误消息的详细信息 要在远程机器上查看,请在“web.config”配置中创建 标记 文件位于当前 Web 应用程序的根目录中。然后,此 标记应将其“模式”属性设置为“关闭”。

 
         
        <!-- Web.Config Configuration File --> 
         
        <configuration> 
            <system.web> 
                <customErrors mode="Off"/> 
            </system.web> 
        </configuration>
                      </td> 
                   </tr> 
          
          </table> 
     
                <br> 
                          <b>Notes:</b> The current error page you are seeing can be replaced by a custom error page by modifying the &quot;defaultRedirect&quot; attribute of the application\'s &lt;customErrors&gt; configuration tag to point to a custom error page URL.<br><br> 
     
                <table width=100% bgcolor="#ffffcc"> 
                   <tr> 
                      <td> 
                          <code><pre> 
     
    &lt;!-- Web.Config Configuration File --&gt; 
     
    &lt;configuration&gt; 
        &lt;system.web&gt; 
            &lt;customErrors mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;mycustompage.htm&quot;/&gt; 
        &lt;/system.web&gt; 
    &lt;/configuration&gt;</pre></code> 
                      </td> 
                   </tr> 
                              </table> 
                <br> 
        </body> 
    </html> 

所以,请让我知道我做错了什么。

卷号介于 1804310011 到 1804310064 之间。

【问题讨论】:

    标签: selenium web-services web-scraping python-requests


    【解决方案1】:

    __VIEWSTATE __VIEWSTATEGENERATOR__EVENTVALIDATION 是服务器应用程序的会话实现。它是动态的,只能使用一次(或几次,在受限上下文中)

    您应该执行两个请求:一个GET GetResult.aspx(检索这些参数)和一个POST Result.aspx 检索结果。

    注意:在继续之前,如果我是你,我会检查是否允许我执行这样的脚本。

    【讨论】:

    • 但是 __VIEWSTATE __VIEWSTATEGENERATOR 和 __EVENTVALIDATION 的值保持不变,因为我打开网站很多次。
    • 您不能确定__EVENTVALIDATION 检查不依赖于您的环境,这与浏览器和请求不同。
    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 2022-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多