【发布时间】:2019-01-13 02:39:08
【问题描述】:
不知道 btnSearch.x 和 btnSearch.y 的值是否用于发布 Search Button 以单击具有以下参数的搜索按钮?
payload={
'today':'20180806'
'sortBy':'',
'alertMsg':'',
'ddlShareholdingDay':'04',
'ddlShareholdingMonth':'06',
'ddlShareholdingYear':'2018',
'btnSearch.x':'????',
'btnSearch.y':'???'
}
import requests
from bs4 import BeautifulSoup
html = "url"
r=requests.post(html, data=payload)
c=r.content
soup=BeautifulSoup(c,"html.parser")
all_tables=[[td.text for td in tr.find_all('td')] for tr in
soup.find_all('table')[2].find_all('tr')]
stock_info=[[sub_item.replace('\r\n', '') for sub_item in item] for item in all_tables]
for stock in stock_info[2:]:
print stock
【问题讨论】:
-
您没有在请求中使用
payload。你试过这样做吗?会发生什么? -
亲爱的,是的,我不知道如何应用有效载荷来发出请求
-
看看docs.python-requests.org/en/master/user/quickstart/…。但也请查看单击搜索按钮时浏览器发出的 POST 请求的详细信息。请求正文包含更多我不理解的数据。
-
试试
r=requests.post(html, data=payload) -
点击按钮?!您正在发送 HTTP 请求 - 您不能“点击”某些东西......如果您想进行真正的点击,您可以使用 Selenium,例如
标签: python beautifulsoup python-requests