This blog is all about Cyber Security and IT

Saturday, February 16, 2019

Scrap data from any Website



Its time to fetch all data from any website . To make it easy , below is a script in which you need to enter the data and get all the desired result .
This is just a sample code to know how to start web scrapping .
Later you can modify the code in whichever way you want .
I used two modules >>
Requests and bs4
To know more about these modules you can check it on google .

Code >>>>>>
import requests
from bs4 import BeautifulSoup

a = input("Enter what you want to search\n")
# Search the text on google
url = ("https://www.google.co.in/search?q=" + a)

response = requests.get(url) # get the response from the URLs

## Passing parameters to the SOUP

soup = BeautifulSoup(response.text)
for item in soup.select(".r a"): ## .r is class and "a" is attribute
print(item.text)

###############################################





CODE Screenshot>>>









OUTPUT>>






0 comments:

Post a Comment