python - 如何使用 python 3.6 抓取 jquery 代码?
问题描述
我需要帮助,我想抓取这个网站。我正在使用BeautifulSoup
, requests
但我无法从图片中获得价值。
import requests
from bs4 import BeautifulSoup
my_url = 'https://partneredge.sap.com/content/partnerfinder/search.html#/'
page = requests.get(my_url)
page_soup = BeautifulSoup(page.content, "lxml")
trazenje = page_soup.find_all('header.search-result__head')
print(trazenje)
结果我得到空列表,没有错误!
解决方案
正如@abarnert 所提到的,您可能需要使用Selenium python 绑定之类的东西来获取该内容:
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']
我会说,如果速度是一个因素,这个选项会很慢,但很容易设置。
推荐阅读
- r - 语法中是否存在带有 stat=identity 参数的 qplot?检查文档但找不到
- java - 如何在 Java SpringBoot 项目中集成 Olingo(Odata)
- arrays - 如何在pinescript中获得给定时间的多个收盘价
- amazon-web-services - Terraform - 仅在 IAM 策略中存在资源时才添加资源
- python - 通过女服务员提供烧瓶应用程序时使用 np.cov 的分段错误
- flutter - IconButton 或任何在抽屉标题内不起作用的按钮
- flutter - Flutter中如何拦截原生网络请求?
- c# - 更新数据库中的产品
- azure - Azure API 管理清除
- python - python中的低通线性滤波器