Skip to content
Advertisement

Python – Extract string from website with Beautifulsoup

I would like to extract a string from a HTML source with only beautifulsoup. I am trying to extract: “1 van de maximaal 3 actieve reacties” from the following HTML:

JavaScript

My current code retrieves the entire span class, but I cannot find out how I can only extract the string, without the use of .split or some sort of string manipulation.

Current code:

JavaScript

Advertisement

Answer

JavaScript

If you have:

JavaScript

You can get 1 van de maximaal 3 actieve reacties by:

JavaScript

A similar thread, where I got the idea from is: How to get text from span tag in BeautifulSoup.

Advertisement