python - 抓取时在元素中查找类
问题描述
解决方案
使用Selenium或BeautifulSoup:
findAll
是一个BeautifulSoup方法download = driver.find_element_by_xpath('//*[@id="post-22276"]/div/div/p[3]/strong')
是SeleniumWebElement
,没有findAll
方法。
这是错误的原因。在这里,您如何获得 Selenium 的下载链接:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
driver.get('https://fullmatchsports.co/amiens-vs-psg-full-match-ligue-1-2018/')
# wait until element will be clickable
wait.until(EC.element_to_be_clickable((By.XPATH, '//p[contains(., "Download links")]//a')))
links = driver.find_elements_by_xpath('//p[contains(., "Download links")]//a')
推荐阅读
- mysql - 加入多个查询结果表
- bash - 如何管理 jq 返回布尔值以 bash 以供将来继续
- angular6 - Angular 6 SSR 错误,而 - !window.ace 未定义。如何为 Ace 编辑器制作 SSR 包装器?
- java - 如何在 Iterable 的 event_date 字段中获取具有最高事件日期的对象的唯一列表
收藏 - sql - 将不同的 ID 拼接成一个唯一 ID
- nginx - 如何配置条件 nginx 代理通行证
- macos - 如何避免无法通过代理建立隧道。代理在 MAC OS 中返回“HTTP/1.1 407 AuthorizedOnly”
- ios - Bundle.main.path(forResource:) 返回 nil
- java - MediaPlayer 在 seek() 调用之前不会播放
- android - Gradle api 与多模块项目中的实现的最佳实践