1

I'm trying to get the content from this web page "http://www.fibalivestats.com/u/ACBS/333409/pbp.html" with this code:

r = requests.get("http://www.fibalivestats.com/u/ACBS/333409/pbp.html")
if r.status_code != 200:
    print("Error!!!")

html = r.content
soup = BeautifulSoup(html, "html.parser")
print(soup)

And I get the template of the page but not the data associated to each tag.

How can I get the data? I'm new in Python.

halfer
  • 19,824
  • 17
  • 99
  • 186
José Carlos
  • 2,850
  • 12
  • 59
  • 95

1 Answers1

3

In this case you have a situation in which the Javascript is not being triggered, thus it is not filling in the elements. It is because there are no DOM elements to be "ready" which normally trigger Javascript actions. I'd suggest you to use a webdriver such as Selenium, as exemplified in here.

It will mimick a Browser and the Javascript will be executed. An example bellow.

from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.fibalivestats.com/u/ACBS/333409/pbp.html")
html_source = browser.page_source
soup = BeautifulSoup(html_source, "html.parser")
Eduardo
  • 4,282
  • 2
  • 49
  • 63