L
L
love_parsing2020-06-16 18:43:42
Python
love_parsing, 2020-06-16 18:43:42

Why is the date not parsed from the page?

Good afternoon everyone. I am writing a Python parser that parses this page https://www.flashscore.ru/match/6PN2l3Bc/#match-summary

(namely, the time, in the upper right corner), but for some reason it displays None when it starts. Why is this happening? Maybe because the code from the page opens in a separate window? PS If you press ctrl + shift + c, a new window will open for some reason. How to parse time from this page? https://www.flashscore.ru/match/6PN2l3Bc/#match-summary

Code:

from selenium import webdriver
from bs4 import BeautifulSoup


def main():
    driver = webdriver.Chrome()
    driver.implicitly_wait(30)
    driver.get('https://www.flashscore.ru/match/6PN2l3Bc/#match-summary')

    html = driver.page_source
    soup = BeautifulSoup(html, 'lxml')

    time = soup.find('div', class_="description__time mstat-date")

    print(time)


if __name__ == '__main__':
    main()


Conclusion:
None

5ee8e89847bd4087315729.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-06-16
@SoreMix

Because this data is not on the page. Crtl+U press and try to find them.
How to parse? - See what request the data comes from and repeat it. Either selenium

R
Rabo, 2020-06-17
@Rabo

Hmm, my first reply got deleted... ok, good memory.
Why is this beautiful soup here? Selenium alone is enough, and if you decide to parse the page this way, then get it without Selenium, because this is a library for tests.
I would do this: In general, I ask you, on behalf of the community, to google more, yandexit, binjit, and, at worst, dakdakgoshit before asking such a simple question. PS Why are you working with this site?
timeStr = driver.find_element_by_id('utime').text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question