T
1

I finally figured out why my Python script kept crashing after 3 hours

Was trying to make a simple web scraper to pull data from a local news site for a project. The problem was a missing 'try-except' block that didn't handle when a page element was empty, so it just stopped after about 500 pages. Took me like 2 days to spot it because the error message wasn't clear at all. Has anyone else run into weird silent fails with BeautifulSoup?
2 comments

Log in to join the discussion

Log In
2 Comments
logansullivan
Why are you even using try-except blocks for that? Just write cleaner code that checks for empty elements before you try to use them. That's basic logic, not an error handling problem.
3
schmidt.blake
But what if the element itself is missing?
2