[英]Submit form and print page with python requests
I have been reading a lot on how to submit a form with python and then read and scrap the obtained page. 我已经阅读了很多有关如何使用python提交表单,然后阅读并废弃获得的页面的内容。 However I do not manage to do it in the specific form I am filling.
但是,我无法按照我填写的特定表格进行操作。 My code returns the html of the form page.
我的代码返回表单页面的html。 Here is my code :
这是我的代码:
import requests
values = {}
values['archive'] = "1"
values['descripteur[]'] = ["mc82", "mc84"]
values['typeavis[]'] = ["10","6","7","8","9"]
values['dateparutionmin'] = "01/01/2015"
values['dateparutionmax'] = "31/12/2015"
req = requests.post('https://www.boamp.fr/avis/archives', data=values)
print req.text
Any suggestion appreciated. 任何建议表示赞赏。
req.text looks like : req.text看起来像:
You may post data to a wrong page. 您可能会将数据发布到错误的页面。 I access the url and post one, then i found the post data is sent to
https://www.boamp.fr/avis/liste
. 我访问该网址并发布一个,然后我发现发布数据已发送到
https://www.boamp.fr/avis/liste
。 (sometime fiddler is useful to figure out the process) (有时提琴手对弄清楚该过程很有用)
So your code should be this 所以你的代码应该是这样
req = requests.post('https://www.boamp.fr/avis/liste', data=values)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.