Skip to content
Advertisement

HTML problem with tags and classes in a simple and little scraping with BeautifulSoup

I am new and am trying to get BeautifulSoup to work. I have Html problems with recovering classes and tags. I get closer, but there is something I’m wrong. I insert wrong tags and classes to scrape the title, time, link, and text of a news item.

I would like to scrape all those titles in the vertical list, then scrape the date, title, link, and content. enter image description here

Can you help me with the right html class and tagging please?

I’m not getting any errors, but the python console stays empty

JavaScript

Code

JavaScript

Advertisement

Answer

Here is a solution you can give it a try,

JavaScript

JavaScript

EDIT:

Why headers are required here ? How to use Python requests to fake a browser visit a.k.a and generate User Agent?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement