selenium - 如何抓取我的拼贴结果网站
问题描述
我想从我的拼贴结果网站收集学生的结果数据 - http://www.bietjhs.ac.in/result2019/GetResult.aspx
所以为此,我使用了requests
python中的模块
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”配置中创建 <customErrors> 标记 文件位于当前 Web 应用程序的根目录中。然后,该 <customErrors> 标记应将其“mode”属性设置为“Off”。
<!-- 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 "defaultRedirect" attribute of the application\'s <customErrors> configuration tag to point to a custom error page URL.<br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre> <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration></pre></code> </td> </tr> </table> <br> </body> </html>
所以,请让我知道我在哪里做错了。
卷号介于 1804310011 到 1804310064 之间。
解决方案
__VIEWSTATE
__VIEWSTATEGENERATOR
并且__EVENTVALIDATION
是服务器应用程序的会话实现。它是动态的,只能使用一次(或几次,在受限上下文中)
您应该执行两个请求:一个GET GetResult.aspx
(检索这些参数)和一个POST Result.aspx
检索结果。
注意:在继续之前,如果我是你,我会检查是否允许我执行这样的脚本。
推荐阅读
- java - MemberSubmissionEndpointReference 类中的 IllegalAnnotationExceptions
- angular - 为什么在遍历列表时无法识别属性?
- ansible - 如何循环 ansible json_query
- go - 如何使用服务帐户密钥 JSON 与服务帐户 JSON 发布到 pubsub
- c# - 如果数字超过某个数字,如何添加 + 号
- java - 在几个节点之前插入到 InsnList
- python - 保存图像文件时在 Flask 中出现错误“ValueError:读取已关闭文件”
- javascript - 如何在 JavaScript 中创建对象数组?
- nlp - 尽管使用了“ContextDependentTokenizerAnnotator”,但为什么 Ctakes 无法识别:“结肠直肠癌”医学文本?
- websphere - WebSphere Application Server 对 MicroProfile 的支持