Python Forum

Full Version: Web scraping data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm new in python and in web scraping, so sorry if my answer is stupid but i don't find anything to do that.

Is it possible to scrap data from a website where the data came from a javascript call.

Eg : I want to scrap the results on this page :

http://www.footlive.com/


Regards,
(Jul-03-2021, 02:34 PM)Mike_Eddy Wrote: [ -> ]Is it possible to scrap data from a website where the data came from a javascript call.
Yes the easiest way is to use Selenium,there are many Thread about this here if search.
Can also look at Web-scraping part-2.

To give a example.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep

#--| Setup
options = Options()
#options.add_argument("--headless")
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
url = "http://www.footlive.com/"
browser.get(url)
sleep(2)
score = browser.find_elements_by_css_selector('#game_1052957 > table > tbody > tr > td:nth-child(3)')[0]
print(score.text)
Output:
Brazil 1 : 0 Chile
(Jul-03-2021, 04:02 PM)snippsat Wrote: [ -> ]
(Jul-03-2021, 02:34 PM)Mike_Eddy Wrote: [ -> ]Is it possible to scrap data from a website where the data came from a javascript call.
Yes the easiest way is to use Selenium,there are many Thread about this here if search.
Can also look at Web-scraping part-2.

To give a example.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep

#--| Setup
options = Options()
#options.add_argument("--headless")
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
url = "http://www.footlive.com/"
browser.get(url)
sleep(2)
score = browser.find_elements_by_css_selector('#game_1052957 > table > tbody > tr > td:nth-child(3)')[0]
print(score.text)
Output:
Brazil 1 : 0 Chile

thank you