install beautifulsouap code example

Example 1: beautifulsoup4 install

pip install beautifulsoup4

Example 2: python bs4 install

pip install bs4 #this'll do the work

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: beautiful soup 4

from bs4 import BeautifulSoup

with open("index.html") as fp:
    soup = BeautifulSoup(fp)

soup = BeautifulSoup("<html>a web page</html>")