Created
September 30, 2019 12:43
-
-
Save lakshay-arora/2eb573835ce2540d109c4b4695bd2ae0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Web Scraping - Scrap Images | |
""" | |
# importing required libraries | |
import requests | |
from bs4 import BeautifulSoup | |
# target URL | |
url = "https://www.goibibo.com/hotels/hotels-in-shimla-ct/" | |
headers = { | |
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" | |
} | |
response = requests.request("GET", url, headers=headers) | |
data = BeautifulSoup(response.text, 'html.parser') | |
# find all with the image tag | |
images = data.find_all('img', src=True) | |
print('Number of Images: ', len(images)) | |
for image in images: | |
print(image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment