how to import beautifulsoup in python code example
Example 1: import beautifulsoup
from requests import get
from bs4 import BeautifulSoup as bs
page = get("http://website.url/goes-here")
soup = bs(page.content, 'html.parser')
Example 2: use beautifulsoup
from bs4 import BeautifulSoup
import requests
req = requests.get('https://www.slickcharts.com/sp500')
soup = BeautifulSoup(req.text, 'html.parser')
Example 3: python import beautifulsoup
from bs4 import BeautifulSoup
import requests
Example 4: beautifulsoup import
from requests import get
from bs4 import BeautifulSoup as bs
page = get("http://dataquestio.github.io/web-scraping-pages/simple.html")
soup = bs(page.content, 'html.parser')
Example 5: beautiful soup 4
from bs4 import BeautifulSoup
with open("index.html") as fp:
soup = BeautifulSoup(fp)
soup = BeautifulSoup("<html>a web page</html>")