I am learning web scrapping since I need it for my work. I wrote the following code:
from selenium import webdriver chromedriver='/home/es/drivers/chromedriver' driver = webdriver.Chrome(chromedriver) driver.implicitly_wait(30) driver.get('http://crdd.osdd.net/raghava/hemolytik/submitkey_browse.php?ran=1955') df = pd.read_html(driver.find_element_by_id("table.example.display.datatable").get_attribute('example'))[0]
However, it is showing the following error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="table.example.display.datatable"]"} (Session info: chrome=103.0.5060.134)
Then I inspect the table that I wanna scrape this table from this page
what is the attribute that needs to be included in get_attribute()
function in the following line?
df = pd.read_html(driver.find_element_by_id("table.example.display.datatable").get_attribute('example'))[0]
what I should write in the driver.find_element_by_id
?
EDITED: Some tables have lots of records in multi-pages. For example, this page has 2,246 entries, which shows 100 entries on each page. Once I tried to web-scrape it, there were only 320 entries in df
and the record ID is from 1232-1713, which means it took entries from the next few pages and it is not starting from the first page to the end at the last page.
What we can do in such cases?