I'm trying to make a web scraper with beautiful soup that will print out the most popular post on reddit and I keep getting an error. Plz explain in simple words if possible. here's the code:
import requests
from bs4 import BeautifulSoup
url = 'https://www.reddit.com/'
response = requests.get(url)
soup = BeautifulSoup(response.content, "html.parser")
article = soup.find('div', attrs={"class": "y8HYJ-y_lTUHkQIc1mdCq _2INHSNB8V5eaWp4P0rY_mE"})
headline = article.a.h3.text
print(headline)
the error:
AttributeError: 'NoneType' object has no attribute 'a'