Intro
In this blog, I am going to extract the information from websites using beautiful soup in Python. It will be displaying the website information on the Python console screen.
Software requirement
Python 3.5 and IDLE (Python 3.5)
Programming code
-
-
- from bs4 import BeautifulSoup
- import requests
- search=input("Enter search term : ")
-
- params={"q": search}
-
- r=requests.get("http://www.google.com",params=params)
-
- soup=BeautifulSoup(r.text)
-
- print(soup.prettify())
About the code
First, I am importing the beautiful soup 4 and request modules.
Next, setting parameter and requesting website code.
Next, using beautiful soup function to get website information.
Finally, I have written the output statement to show the website information in the console.
Then, let’s execute the code.
Output