How to get the HTML content of any website in a readable form
we can read the HTML content of any website.
we use two modules the first module is request and bs4 module
we use request module for get the HTML code of website and bs4 module use for arranging the
unreadable HTML code in readable form
request .get is used for get the HTML code
source code:
import requests
from bs4 import BeautifulSoup
html_code=requests.get("URL")
#this get the code of website
print(html_code.text)
#This print the html code but we cannot read this code
# then we use bs4 module
# lets see the doc of bs4 module
soup = BeautifulSoup(html_code, 'html.parser')
soup_my=soup.prettify()
print(soup_my)
# lets see it print the html code in readable form
No comments:
Post a Comment