Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想使用selenium和python来获取使用';邮政';方法_Python_Python 3.x_Scrapy - Fatal编程技术网

我想使用selenium和python来获取使用';邮政';方法

我想使用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

我想使用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.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'])