gpt4 book ai didi

python - 不知道发布搜索按钮的 btnSearch.x 和 btnSearch.y 值

转载 作者:太空宇宙 更新时间:2023-11-04 04:36:02 24 4
gpt4 key购买 nike

不知道 btnSearch.x 和 btnSearch.y 值用于发布搜索按钮以使用以下参数单击搜索按钮?

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

最佳答案

btnSearch.xbtnSearch.y 值并不重要,它们只是 btnSearch 图像的鼠标坐标(我认为) ,并且对 POST 请求没有任何影响。

但是,ASP.NET Web 应用程序会使用一些重要的隐藏字段(__VIEWSTATE__EVENTVALIDATION)。我们可以找到这些值并将它们与 POST 数据一起提交。

import requests
from bs4 import BeautifulSoup

url = 'url'
s = requests.session()
r = s.get(url)
soup = BeautifulSoup(r.text, 'html.parser')

data = {i['name']: i.get('value') for i in soup.select('input')}
data['ddlShareholdingDay'] = '04'
data['ddlShareholdingMonth'] = '06'
data['ddlShareholdingYear'] = '2018'
data['btnSearch.x'] = '????'
data['btnSearch.y'] = '???'

r = s.post(url, data)
soup = BeautifulSoup(r.text, 'html.parser')
stock_info = [
[td.text.strip() for td in tr.find_all('td')]
for tr in soup.find_all('table')[2].find_all('tr')
]
for stock in stock_info[2:]:
print(stock)

关于python - 不知道发布搜索按钮的 btnSearch.x 和 btnSearch.y 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51702498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com