You can call CSS class in bs4 bye using
Example:
_
class_="text"
.Example:
import requests from bs4 import BeautifulSoup html = requests.get("http://www.pythonscraping.com/pages/warandpeace.html") soup = BeautifulSoup(html.content, 'html.parser') red_text = soup.find('span', class_="red") print(red_text.text)
Output:Well, Prince, so Genoa and Lucca are now just family estates of the
Buonapartes. But I warn you, if you don't tell me that this means war,
if you still try to defend the infamies and horrors perpetrated by
that Antichrist- I really believe he is Antichrist- I will have
nothing more to do with you and you are no longer my friend, no longer
my 'faithful slave,' as you call yourself! But how do you do? I see
I have frightened you- sit down and tell me all the news.
Se that i don't use camelCase at all,so findAll()
work but it's there Backward compatibility(bs3) correct way is find_all()
.