bs4 html.parser code example
Example 1: use beautifulsoup
from bs4 import BeautifulSoup
import requests
req = requests.get('https://www.slickcharts.com/sp500')
soup = BeautifulSoup(req.text, 'html.parser')
Example 2: beautiful soup 4
from bs4 import BeautifulSoup
with open("index.html") as fp:
soup = BeautifulSoup(fp)
soup = BeautifulSoup("<html>a web page</html>")
Example 3: children beautiful soup
li = soup.find('li', {'class': 'text'})
children = li.findChildren("a" , recursive=False)
for child in children:
print child
Example 4: beautifulsoup find class
mydivs = soup.findAll("div", {"class": "stylelistrow"})