V
V
Vasily Kuzin2019-12-21 18:01:20
Python
Vasily Kuzin, 2019-12-21 18:01:20

Why is BeautifulSoup not working properly on Heroku server?

I am making a Telegram bot that should parse sporting events. There is this request:

today = str(datetime.today()).split()[0]
url = 'https://www.championat.com/stat/football/#' + today
headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
r = requests.get(url, headers=headers)
html = BeautifulSoup(r.text, 'html.parser')
[s.extract() for s in html('script')]

Both locally and on the Heroku server everything works fine. Next, I want to take some blocks with BeautifulSoup:
tournaments = html.findAll("div", {"class": "seo-results__tournament"})
matches = html.find("div", {"class": "seo-results"}).findAll("ul")

Locally everything works fine, but when I upload the bot to Heroku it .findalways returns None. How can this be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question