I'm new to web scraping, and I'm trying to pull all the names of all the journals from this website: https://ideas.repec.org/top/top.journals.simple.html.
Here's my attempt so far (following the tutorial here https://www.pluralsight.com/guides/extracting-data-html-beautifulsoup):
import requests
from bs4 import BeautifulSoup
URL = "https://ideas.repec.org/top/top.journals.simple.html"
html_content = requests.get(URL).text
soup = BeautifulSoup(html_content, "lxml"
journal_list = soup.find("table", attrs={"class": "toplist"})
journal_list_data = journal_list.tbody.find_all("tr")
headings = []
for td in journal_list_data[0].find_all("td"):
headings.append(td.b.text.replace('\n', '').strip())
print(headings)
This is just to get a list of the table headings, and then I'll try to pull all the journal names from the 'Journal' column, but I'm getting an AttributeError basically saying that journal_list.tbody is NoneType, and when I check journal_list.attrs it only gives {'class': 'toplist'), even though the HTML on the page definitely has a tbody attribute.
What am I doing wrong/are there other, better ways to do this?
Thanks!