py4e-int
Social
Runestone in social media:
Follow @iRunestone
Our Facebook Page
Help support us:
Search
Table of Contents
Book Index
User
Assignments
Practice
Peer Instruction (Instructor)
Peer Instruction (Student)
Change Course
Instructor's Page
Progress Page
Edit Profile
Change Password
Register
Login
Dark Mode
Scratch Activecode
Help
FAQ
Instructors Guide
About Runestone
Report A Problem
This Chapter
14.14.
You can download all the plans here
¶
14.14.1.
Plan 1
¶
# Get the webpage _____________________________________________ # Extract info from the page _____________________________________________ # Do something with the info _____________________________________________
14.14.2.
Plan 2
¶
# 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')
14.14.3.
Plan 3
¶
# 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')
14.14.4.
Plan 4
¶
# Get first tag of a certain type from the soup tag = soup.find(___________) # Get info from the tag info = tag.________
14.14.5.
Plan 5
¶
# 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: # Get info from tag info = tag.________ collect_info.append(info)
14.14.6.
Plan 6
¶
# 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: # Get info from tag info = tag.________ collect_info.append(info)
14.14.7.
Plan 9
¶
# Print info print(____________)
14.14.8.
Plan 10
¶
# Load library for json files import json # Put info into file f = open(____________, 'w') json.dump(____________, f) f.close()
You have attempted
of
activities on this page