r/PythonLearning • • 1h ago

Beginner struggling with web scraping multiple Wikipedia pages using BeautifulSoup in Spyder

Hi everyone!

I'm fairly new to Python and currently learning web scraping using Spyder, BeautifulSoup, and requests.

I've been trying to write a script that extracts data from a Wikipedia table, collects the links from the table, and then visits each link to scrape the corresponding Wikipedia article.

I've managed to get some parts working, but I'm struggling to figure out whether my approach is correct and if there are any mistakes in my code.

I'm particularly unsure about how I'm extracting the links and downloading the individual pages.

I would really appreciate some guidance on how to troubleshoot this or improve my approach.

I'm not looking for someone to write the code for me, just some explanations or pointers so I can understand what I'm doing wrong.

Thanks in advance!

2 Upvotes

1 comment sorted by

3

u/sausix 43m ago
  1. Screenshots of code are annoying. Don't think people always can spot bugs directly by reading. Some people may try tonrun your code but they don't wanna type your code first.
  2. Wikipedia data is officially downloadable. If you just wanna learn or just scrape a few pages only then it's fine.
  3. Debug your code. Run step by step, view or track variables. Because you have to learn debugging anyway and you learn the most when you hunt your own bugs.
  4. "Something does not work in my (huge) code" is a bad way to ask for help. Error messages are the key and should not be ignored. Even cryptical error messages are very helpful.

So please explain what exactly is happening or not. Do some basic debugging yourself. Even using print markers to follow execution is fine. Without own effort people get usually less or lousier help.