I'm trying to do some webscraping but it keeps showing no tables found but there is literally a table on the website. Maybe I'm not writing the right code. Someone help. Here is the link to the website. Film-Locations-in-San-Francisco
-
Welcome to SO! What is the code you have tried so far? It would help your question if you researched how to properly format it. Also, there are plenty of posts out there already about scraping HTML tables in Python.dcsuka– dcsuka2022-08-21 02:45:37 +00:00Commented Aug 21, 2022 at 2:45
-
Please provide enough code so others can better understand or reproduce the problem.Community– Community Bot2022-08-21 02:58:18 +00:00Commented Aug 21, 2022 at 2:58
Add a comment
|
1 Answer
I guess you are using requests. But you should note that the requests does not receive the table because the table is generated after rendering the page and it is not exists in the requests data. A basic way is to use something like Selenium to first load the page then retrieve the information.
Based on your comment use something similar to:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r"C:/Users/user/Desktop/chromedriver_win32/chromedriver.exe")
driver.get("https://data.sfgov.org/Culture-and-Recreation/Film-Locations-in-San-Francisco/yitu-d5am/data")
elem = driver.find_element_by_xpath('//*[@id="renderTypeContainer"]/div[4]/div[2]/div/div[4]/div[1]/div/table')
elem.text
#driver.close()
3 Comments
Divine
This is the code I used i.sstatic.net/5MY75.png
keramat
This does not work? I will try to develop a version with selenium.
keramat
Look at the answer again.