Skip to content

Instantly share code, notes, and snippets.

@lakshay-arora
Last active September 30, 2019 09:05
Show Gist options
  • Save lakshay-arora/7ea17e4fb561bda32ee28d212c9eadb0 to your computer and use it in GitHub Desktop.
Save lakshay-arora/7ea17e4fb561bda32ee28d212c9eadb0 to your computer and use it in GitHub Desktop.
"""
Web Scraping - Beautiful Soup
"""
# importing required libraries
import requests
from bs4 import BeautifulSoup
import pandas as pd
# target URL to scrap
url = "https://www.goibibo.com/hotels/hotels-in-shimla-ct/"
# headers
headers = {
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
}
# send request to download the data
response = requests.request("GET", url, headers=headers)
# parse the downloaded data
data = BeautifulSoup(response.text, 'html.parser')
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment