我想使用selenium和python来获取使用';邮政';方法
我想使用selenium和python获取名为'投资金额' 而且投资数量' 在示例1的黑框中,哪个请求方法是“post”。我的代码如下,这是开了又关。需要你的帮助我想使用selenium和python来获取使用';邮政';方法,python,python-3.x,scrapy,Python,Python 3.x,Scrapy,我想使用selenium和python获取名为'投资金额' 而且投资数量' 在示例1的黑框中,哪个请求方法是“post”。我的代码如下,这是开了又关。需要你的帮助 from selenium import webdriver from bs4 import BeautifulSoup browser = webdriver.Chrome() browser.get("https://www.pedata.cn/invest_count/list.html") html = browser.pag
from selenium import webdriver
from bs4 import BeautifulSoup
browser = webdriver.Chrome()
browser.get("https://www.pedata.cn/invest_count/list.html")
html = browser.page_source
soup = BeautifulSoup(html, 'html.parser')
invest = soup.find('div', 'tj_chart').find('div')
print(invest.string)
在这个网站中,数据并没有嵌入到html页面中,而是通过Javascript从另一个API(POST)加载的。获取图表中所有数据的最简单方法是直接调用该API,而不是等待JS加载数据:
import requests
response = requests.post(
'https://www.pedata.cn/ajax/invest_count/list',
data = {
'investStart': '',
'investEnd': '',
'x': 1,
'currency': '',
'month': '',
'round': '',
'investStage': '',
'investType': '',
'investTime': '',
'xType': '',
'city': '',
'industry': ''
}
)
print(response.json()['data'])