Nov-07-2019, 02:37 PM
(This post was last modified: Nov-07-2019, 02:37 PM by Captain_Snuggle.)
Hi guys,
I have recently started learning Python, and have now started learning webscraping with BeautifulSoup. The following code is not working for me in Pycharm. I hope someone can help me with my problem. It would be greatly appreciated :)
I have recently started learning Python, and have now started learning webscraping with BeautifulSoup. The following code is not working for me in Pycharm. I hope someone can help me with my problem. It would be greatly appreciated :)
import requests
from bs4 import BeautifulSoup
data=requests.get('https://umggaming.com/leaderboards')
soup=BeautifulSoup(data.text, 'html.parser')
leaderboard=soup.find('div', { 'id': 'leaderboard-table' })
tbody=leaderboard.find('tbody')
for tr in tbody.find_all('tr'):
place=tr.find_all('td')[0].text.strip()
username=tr.find_all('td')[1].find_all('a')[1].text.strip()
xp=tr.find_all('td')[3].text.strip()
print(place, username, xp)I get the following error note: tbody=leaderboard.find('tbody')
AttributeError: 'NoneType' object has no attribute 'find'
