小编Tim*_*tty的帖子

我可以使用 requests.post 提交表单吗?

我试图从这个站点获取商店列表:http : //www.health.state.mn.us/divs/cfh/wic/wicstores/

我想获取当您单击“查看所有商店”按钮时生成的商店列表。我知道我可以使用 Selenium 或 MechanicalSoup 或...来做到这一点,但我希望使用请求。

看起来点击按钮提交了一个表单:

 <form name="setAllStores" id="setAllStores" action="/divs/cfh/wic/wicstores/index.cfm" method="post" onsubmit="return _CF_checksetAllStores(this)">
<input name="submitAllStores" id="submitAllStores"  type="submit" value="View All Stores" />
Run Code Online (Sandbox Code Playgroud)

但我不知道如何编写请求查询(或者甚至可能的话)。

到目前为止,我尝试的原因是以下方面的变化:

SITE = 'http://www.health.state.mn.us/divs/cfh/wic/wicstores/'
data = {'name': 'setAllStores', 'form': 'submitAllStores', 'input': 'submitAllStores'}
r = requests.post(SITE, data)
Run Code Online (Sandbox Code Playgroud)

但这不起作用。欢迎任何帮助/建议。

python beautifulsoup web-scraping python-requests

1
推荐指数
1
解决办法
4202
查看次数