Python Forum
Web scraping data - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Web scraping data (/thread-34168.html)



Web scraping data - Mike_Eddy - Jul-03-2021

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,


RE: Web scraping data - snippsat - Jul-03-2021

(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



RE: Web scraping data - Mike_Eddy - Jul-03-2021

(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