1

I am trying to fetch a specific table from a webpage using BeautifulSoup4 and Selenium the table is present there but it is not fetching using this code. I tried this

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 and the Result DisplayResult

Platform and tools

  • Microsoft Windows 10 x64
  • Using Chromium Webdriver ( installed version 32bit)

Edited. I already Tried

table = driver.get_element_by_id('tournamentgrid-1538318460041')

&

table = driver.get_element_by_xpath('//*[@id="tournamentgrid-1538398792982"]')

1 Answers1

0

You can try accessing table using its xpath

driver.find_element_by_xpath('xpath_here')

or alternatively you can get all table rows(all <tr> element objects) by

driver.find_elements_by_xpath('xpath_here') 

and traverse through the list of row elements to extract required data, like using .text to extract text visit https://selenium-python.readthedocs.io/api.html for more details

dc7
  • 401
  • 1
  • 4
  • 13