Skip to content
Advertisement

Beautiful Soup and requests problem it doesn’t show any text output

I am using beautiful soup and requests to print full text of the article of this wedsite

https://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture

This is my code:

JavaScript

My code run without any error but it does’t show any text in output plz help me find my error

Advertisement

Answer

What happens?

You try to find_all() div tags with two classes that do not exists, so match is empty.

How to fix that?

Use the correct pattern, I took the css selectors to avoid an additional loop:

JavaScript

List comprehension then looks like:

JavaScript

Working example

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