soup.find_all python code example
Example 1: beautifulsoup4 install
pip install beautifulsoup4
Example 2: beautifulsoup find all class
mydivs = soup.findAll("div", {"class": "stylelistrow"})
Example 3: use beautifulsoup
#start
from bs4 import BeautifulSoup
import requests
req = requests.get('https://www.slickcharts.com/sp500')
soup = BeautifulSoup(req.text, 'html.parser')
Example 4: python beautifulsoup find_all
import re
soup.find_all(re.compile("^b")):
soup.find_all('b')
soup.find_all(["a", "b"])
Example 5: soup.find_all attr
british = tabEntry.find(‘div’, class_=’tabs__content on’, attrs={‘data-tab’: ‘ds-british’})business = tabEntry.find(‘div’, class_=’tabs__content on’, attrs={‘data-tab’: ‘ds-business-english’})example = tabEntry.find(‘div’, class_=’tabs__content on’, attrs={‘data-tab’: ‘ds-example’})