beautifulsoup examples

Example 1: use beautifulsoup

#start


from bs4 import BeautifulSoup
import requests

req = requests.get('https://www.slickcharts.com/sp500')
soup = BeautifulSoup(req.text, 'html.parser')

Example 2: children beautiful soup

li = soup.find('li', {'class': 'text'})
children = li.findChildren("a" , recursive=False)
for child in children:
    print child

Example 3: beautifulsoup example

import requests
page = requests.get("http://dataquestio.github.io/web-scraping-pages/simple.html")
page