【发布时间】:2019-03-06 01:12:20
【问题描述】:
我正在尝试使用 BeautifulSoup4 和 Selenium 从网页中获取特定表,该表存在于那里,但没有使用此代码获取。 我试过这个
from bs4 import BeautifulSoup
from selenium import webdriver
import time
driver = webdriver.Chrome()
url = 'https://de.sharkscope.com/#Find-Tournament/networks/PokerStars/tournaments/2412466083'
driver.get(url)
res = driver.execute_script("return document.documentElement.outerHTML")
time.sleep(5)
driver.quit()
soup = BeautifulSoup(res, 'lxml')
targetTable = soup.findAll('table', {'id': 'tournamentgrid-1538318460041'})
print(targetTable)
screenshot table With ID 和结果 DisplayResult
平台和工具
- Microsoft Windows 10 x64
- 使用 Chromium Webdriver(已安装 32 位版本)
已编辑。我已经试过了
table = driver.get_element_by_id('tournamentgrid-1538318460041')
&
table = driver.get_element_by_xpath('//*[@id="tournamentgrid-1538398792982"]')
【问题讨论】:
标签: python selenium selenium-webdriver beautifulsoup dynamic-tables