Plan 1: Get a soup from a URL¶
Plan 1: Example¶
The first step in web scraping is getting information from a webpage. To use the BeautifulSoup web scraping library, we have to put the webpage into something called a soup.
Here is the code for getting a soup from the Cottage Inn location page.
Goal: Get a soup from one webpage# Load libraries for web scraping from bs4 import BeautifulSoup import requests # Get a soup from a URL url = 'https://cottageinn.com/pick-a-location/' r = requests.get(url) soup = BeautifulSoup(r.content, 'html.parser')
Plan 1: When to use this plan¶
Use this plan when you want to scrape one webpage.
Plan 1: How to use this plan¶
Replace the URL with the URL of the website you want to scrape.