Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.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
如何使用Python3.6刮取jquery代码?_Python_Python 3.x_Web Scraping_Beautifulsoup_Python Requests - Fatal编程技术网

如何使用Python3.6刮取jquery代码?

如何使用Python3.6刮取jquery代码?,python,python-3.x,web-scraping,beautifulsoup,python-requests,Python,Python 3.x,Web Scraping,Beautifulsoup,Python Requests,我需要帮助,我想刮这个网站。我使用的是BeautifulSoup和请求,但我无法从图片中获取值 我得到的结果是空列表,没有错误 正如@abarnert所提到的,您可能需要使用类似的工具来获取该内容: from selenium import webdriver driver = webdriver.Chrome() driver.get('https://partneredge.sap.com/content/partnerfinder/search.html#/') table = dr

我需要帮助,我想刮这个网站。我使用的是
BeautifulSoup
请求
,但我无法从图片中获取值

我得到的结果是空列表,没有错误


正如@abarnert所提到的,您可能需要使用类似的工具来获取该内容:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://partneredge.sap.com/content/partnerfinder/search.html#/')

table = driver.find_elements_by_xpath('//article//header//a')

results = []
for tag in table:
    results.append(tag.text)
print(results)
这将产生以下输出:

['Accenture', 'Capgemini AB', 'Deloitte Inc.', 'IBM Corporation International Technical', 'itelligence AG', 'SEIDOR, S.A.', 'GAVDI A/S', 'Navigator Business Solutions, Inc.', 'Delaware Consulting US Inc.', 'Ernst & Young LLP']

我会说,如果速度是一个因素,那么这个选项相当慢,但是设置起来很容易。

发布代码、预期结果和实际结果或错误我发布代码ty:)这些元素在下载的页面上不存在。在浏览器中,它们是通过一些JavaScript加载后添加的。你没有运行那个JavaScript。如果你想抓取这个网站,你需要(1)使用Selenium之类的东西驱动浏览器,(2)运行PhantomJS之类的JavaScript引擎,(3)阅读JS的功能并编写等效的Python,或者(4)通过观察来自浏览器的传出请求并编写Python来反向设计JS的功能。同时,他们的ToS允许你这么做吗?如果是的话,他们很有可能有一个API,他们希望你使用,而不是刮他们的页面;你看过了吗?如果这是不允许的,即使你不在乎他们的规则,他们也很有可能在几次请求后自动检测到你的刮擦并阻止你。没有检查过吗,快速提示@abarnert:DDo我需要为此安装Chrome?我收到一个错误selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要位于路径中。请查看安装页面上是否有建议的四种浏览器:Chrome、Edge、Safari或Firefox。您可以使用其中任何一种,但请遵循安装指南。您需要将chromedriver.exe的父文件夹添加到系统路径。只需谷歌如何根据您的操作系统来实现这一点。
['Accenture', 'Capgemini AB', 'Deloitte Inc.', 'IBM Corporation International Technical', 'itelligence AG', 'SEIDOR, S.A.', 'GAVDI A/S', 'Navigator Business Solutions, Inc.', 'Delaware Consulting US Inc.', 'Ernst & Young LLP']