Using Beautiful Soup In Python

Introduction

 
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 
  1. #Extracting URL's from any website using beautifulSoup  
  2. #import packages  
  3. from bs4 import BeautifulSoup  
  4. import requests  
  5. search=input("Enter search term : ")  
  6. #set parameter  
  7. params={"q": search}  
  8. #request  
  9. r=requests.get("http://www.google.com",params=params)  
  10. #using beautifulSoup fuction  
  11. soup=BeautifulSoup(r.text)  
  12. #output statement  
  13. print(soup.prettify())  
About the code
 
First, I am importing the beautiful soup 4 and request modules.
 
Next, setting parameters and requesting website code.
 
Next, using a 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