Section14.6Write Code Questions - Parsons for Select
Activity14.6.1.
Create a function called cur_stud_link(soup) that takes a soup object and returns the URL that links to Current Students in the Navigation Bar. The soup object is created from the file UMich-8-16-2026.html which is a saved version of “https://umich.edu/” from 2026. Click on the following link to view the source:link. For example, cur_stud_link(soup) should return 'https://umich.edu/web/20260808043645/https://umich.edu/current-students/'.
Create a function called headings(soup) that takes a soup object and returns a list of the text from all h2 tags in the soup. The soup object is created from the file MOOC-Wikipedia-8-20-2026.html which is a saved version of “https://en.wikipedia.org/wiki/Massive_open_online_course” from 2026. Click on the following link to view the source: link For example, headings(soup) should return a list of 14 headings starting with ['Contents', 'History', 'Equity and access', ...].
Create a function called coursera_dict(soup) that takes a soup object and returns a dictionary with Country as keys and Percentage as values. The soup object is created from the file ’WikipediaMOOC-Jan-12-2018.html’ which is a saved version of “https://en.wikipedia.org/wiki/Massive_open_online_course” from 2018. Click on the following link to view the source: link For example, coursera_dict(soup) should return a dictionary like: {'United States': '27.7%', 'India': '8.8%', 'Brazil': '5.1%', ...}.
Create a function called keywords(soup) that takes a soup object and returns a list of Python keywords. The soup object is created from the file PythonKeywords.html which is a saved version of “https://www.w3schools.com/python/python_ref_keywords.asp” from 2026. Click on the following link to view the source: link. For example, keywords(soup) should return a list that starts with: ['and', 'as', ...].
Create a function called restaurants_list(file) that takes in a file name as file, uses BeautifulSoup to web scrape the 13 best restaurants in Ann Arbor as of 2026, For example, restaurants_list('AnnArborBestRestaurants2026.html') should return ['Sava’s', 'Knight’s Steakhouse', 'Mani Osteria and Bar', ...]. The current url is “https://detroit.eater.com/maps/best-ann-arbor-restaurants”. We are using a saved version of that site from Aug 1 2026. Click on the following link to view the source link.
Create a function called bsi_list that takes in a parameter url, uses BeautifulSoup to web scrape the section names and subsection names under Programs Bachelor of Science in Information, and returns a list of the section names and subsection names under Programs Bachelor of Science in Information. For example, bsi_list('https://www.si.umich.edu/programs/bachelor-science-information') should return ['How do I apply?', 'Current U-M students', 'Transfer students', ...]. Since we are scraping a live site the results may be different.
Create a function called bsi_dict that takes in a parameter url, uses BeautifulSoup to web scrape and create a list of the section names and subsection names under Programs Bachelor of Science in Information, and creates another list that contains the full urls of the named sections and subsections. Then, return a dictionary that contains the names as keys and their full urls as values. For example, bsi_dict('https://www.si.umich.edu/programs/bachelor-science-information') should return {'How do I apply?': 'https://www.si.umich.edu/.../how-do-i-apply', ...}. Since we are scraping a live site the results may be different.
Create a function called envelope_address that takes in a parameter url and uses BeautifulSoup to web scrape and return the address text in the footer as a list. For example, envelope_address('https://www.si.umich.edu/programs/bachelor-science-information') should return a list like: ['School of Information', 'University of Michigan', ...]. Since we are scraping a live site the results may be different.
Create a function called name_email that takes in a parameter url, uses BeautifulSoup to web scrape the names and email addresses, and returns a dictionary with the names as keys and the email addresses as values. Use the string replace method while web scraping. For example, name_email('https://www.si.umich.edu/people/directory/faculty/e') should return {'Paul Edwards': '[email protected]', 'Ron Eglash': '[email protected]', ...}. Since we are scraping a live site the results may be different.
Create a function called program_email that takes in a parameter url, uses BeautifulSoup to web scrape the program names under Email Addresses and Admissions (BSI program, MSI program, etc.) and their associated email addresses, and returns a dictionary with the program names as keys and the email addresses as values. For example, program_email('https://www.si.umich.edu/about-umsi/contact-us') should return something like {'BSI program': '[email protected]', 'MSI program': '[email protected]', ...}. Since we are scraping a live site the results may be different.