如何使用请求和pyqt5获取Web数据?

时间:2019-01-23 07:51:42

标签: python python-requests pyqt5

我想从http://www.sse.com.cn/assortment/stock/list/info/announcement/index.shtml那里获取数据

您可以看到五个方框。 我想输入如图所示的信息。 enter image description here

我尝试使用requests

import requests

url = r'http://www.sse.com.cn/assortment/stock/list/info/announcement/index.shtml'
payload = {'inputCode': '600000', 'single_select_2':'DQGG', 'start_date': '2018-06-01', 'end_date':'2019-01-23'}
response = requests.post(url, data = payload)

但是,我无法获得正确的结果。

正确的方法是什么?

如何使用pyqt5来做到这一点?

1 个答案:

答案 0 :(得分:0)

您需要使用Python Selenium来实现。不管您是否知道所需的数据,Post API都是不公开的,因此开发人员无法使用它。

尝试使用Selenium,它对于Web抓取和Web自动化非常容易。这是一些启蒙命令/功能。

driver.get(web_url)
driver.find_element_by_xpath(xpath).click()
driver.find_element_by_xpath(xpath).send_keys('asd')