Activity 14.10.1.
Choose which of the following plans you will use, and put them in the correct order.
# Load libraries for web scraping
from bs4 import BeautifulSoup
import requests
# Get a soup from multiple URLs
base_url = ________________________________
endings = ________________________________
for ending in endings:
url = base_url + ending
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
---
# Load libraries for web scraping
from bs4 import BeautifulSoup
import requests
# Get a soup from a URL
url = _________________________
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser') #distractor
---
# Get all tags of a certain type from the soup
tags = soup.find_all(___________)
# Collect info from the tags
collect_info = []
for tag in tags:
info = tag.____________
collect_info.append(info)
---
# Get first tag of a certain type from the soup
tag = soup.find(___________)
# Get info from the tag
info = tag.____________ #distractor
---
# Get first tag of a certain type from the soup
first_tag = soup.find(___________)
# Get all tags of a certain type from the first tag
tags = first_tag.find_all(____________)
# Collect info from the tags
collect_info = []
for tag in tags:
info = tag.____________
collect_info.append(info) #distractor
---
# Print the info
print(____________)
---
# Load library for json files
import json
# Put info into file
f = open(____________, 'w')
json.dump(____________, f)
f.close() #distractor




