Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.findAll()
#5
You can call CSS class in bs4 bye using _ 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().
Reply


Messages In This Thread
.findAll() - by Truman - Nov-14-2018, 10:42 PM
RE: .findAll() - by Gribouillis - Nov-14-2018, 10:49 PM
RE: .findAll() - by Truman - Nov-14-2018, 10:52 PM
RE: .findAll() - by Gribouillis - Nov-14-2018, 11:05 PM
RE: .findAll() - by Truman - Nov-16-2018, 12:21 AM
RE: .findAll() - by snippsat - Nov-14-2018, 11:37 PM
RE: .findAll() - by snippsat - Nov-16-2018, 12:51 PM
RE: .findAll() - by Truman - Nov-17-2018, 12:08 AM
RE: .findAll() - by snippsat - Nov-17-2018, 01:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  re.findall help searching for string in xml response mugster 2 3,376 May-30-2018, 03:27 PM
Last Post: mugster
  Different Output of findall and search in re module shiva 1 2,394 Mar-12-2018, 08:39 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020