Write Code Questions¶
Write a function called
cur_stud_link
that takes in a parameterurl
and uses BeautifulSoup to return the URL that links to Current Students in the Navigation Bar. For example,cur_stud_link('https://umich.edu/')
should return"https://umich.edu/current-students/"
.Write a function called
cur_stud_link
that takes in a parameterurl
and uses BeautifulSoup to return the URL that links to Current Students in the Navigation Bar. For example,cur_stud_link('https://umich.edu/')
should return"https://umich.edu/current-students/"
.-
Write a function called
headings
that takes in a parameterurl
and uses BeautifulSoup to return a list of all heading names (not subheadings) from the Contents box (History, Emergence of MOOC providers, Student experience and pedagogy, etc.). For example,headings('https://en.wikipedia.org/wiki/Massive_open_online_course')
should return a list of headings like:['History', 'Emergence of MOOC providers', 'Student experience and pedagogy', 'Information architecture', 'Industry', 'Benefits', 'Challenges and criticisms', 'See also', 'References', 'Further reading', 'External links']
. Since we are scraping a live site the actual values may be different. Write a function called
coursera_dict
that takes in a parameterurl
, uses BeautifulSoup to web scrape the Coursera enrollees table, and returns a dictionary with Country as keys and Percentage as values. For example,coursera_dict('https://en.wikipedia.org/wiki/Massive_open_online_course')
should return a dictionary like:{'United States': '27.7%', 'India': '8.8%', 'Brazil': '5.1%', 'United Kingdom': '4.4%', 'Spain': '4.0%', 'Canada': '3.6%', 'Australia': '2.3%', 'Russia': '2.2%', 'Rest of world': '41.9%'}
. Since we are scraping a live site the actual values may be different.Write a function called
coursera_dict
that takes in a parameterurl
, uses BeautifulSoup to web scrape the Coursera enrollees table, and returns a dictionary with Country as keys and Percentage as values. For example,coursera_dict('https://en.wikipedia.org/wiki/Massive_open_online_course')
should return{'United States': '27.7%', 'India': '8.8%', 'Brazil': '5.1%', 'United Kingdom': '4.4%', 'Spain': '4.0%', 'Canada': '3.6%', 'Australia': '2.3%', 'Russia': '2.2%', 'Rest of world': '41.9%'}
.-
Write a function called
types
that takes in a parameterurl
, uses BeautifulSoup to web scrape the Summary of Python 3’s built-in types table, and returns a list of the types. For example,types('https://en.wikipedia.org/wiki/Python_(programming_language)')
should return a list of string like:['bool', 'bytearray', 'bytes', 'complex', 'dict', 'types.EllipsisType', 'float', 'frozenset', 'int', 'list', 'types.NoneType', 'types.NotImplementedType', 'range', 'set', 'str', 'tuple']
. Since we are scraping a live site the actual values may be different. Write a function called
restaurants_list
that takes in a parameterurl
, uses BeautifulSoup to web scrape the 12 essential Ann Arbor restaurants, and returns a list of the 12 best Ann Arbor restaurants. For example,restaurants_list('https://detroit.eater.com/maps/best-ann-arbor-restaurants')
should return a list of restaurants like:['1. Salt Springs Brewery', "2. Knight's Steakhouse", '3. The Last Word', "4. Krazy Jim's Blimpy Burger", '5. Blue Llama Jazz Club', '6. Spencer', '7. Miss Kim', "8. Zingerman's Delicatessen", '9. Tomukun Noodle Bar', '10. Ricewood', '11. Bellflower', "12. Ma Lou's Fried Chicken"]
. Since we are scraping a live site the actual values may be different.Write a function called
restaurants_list
that takes in a parameterurl
, uses BeautifulSoup to web scrape the 12 essential Ann Arbor restaurants’ names, and returns a list of the 12 best Ann Arbor restaurants in 2019. For example,restaurants_list('https://detroit.eater.com/maps/best-ann-arbor-restaurants')
should return["1. Knight's Steakhouse", '2. The Last Word', "3. Krazy Jim's Blimpy Burger", '4. Blue Llama Jazz Club', '5. Spencer', '6. Miss Kim', "7. Zingerman's Delicatessen", '8. Tomukun Noodle Bar', '9. Seoul Street', '10. Ricewood', '11. Bellflower', "12. Ma Lou's Fried Chicken"]
.-
Write a function called
bsi_list
that takes in a parameterurl
, 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 a list like:['How do I apply?', 'Current U-M students', 'Transfer students', 'High school students', 'New transfers', 'Curriculum', 'Career outcomes', 'Internships', 'Career development resources', 'Engaged learning', 'Tuition and funding', 'Connect with us', "Accelerated Master's Degree Program", 'Study abroad for undergraduates', 'Exchange student information']
. Since we are scraping a live site the actual values may be different. Write a function called
bsi_dict
that takes in a parameterurl
, uses BeautifulSoup to web scrape and create a list of the section names and subsection names under Programs Bachelor of Science in Information, and returns 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 a dictionary like:{'How do I apply?': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply', 'Current U-M students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/cross-campus-transfer', 'Transfer students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/new-transfer-students-bsi', 'High school students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/preferred-admissions', ... 'Exchange student information': 'https://www.si.umich.edu//programs/bachelor-science-information/exchange-student-information'}
. Since we are scraping a live site the actual values may be different.Write a function called
bsi_dict
that takes in a parameterurl
, uses BeautifulSoup to web scrape and create a list of the section names and subsection names under Programs Bachelor of Science in Information, and returns 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 a dictionary like:{'How do I apply?': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply', 'Current U-M students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/cross-campus-transfer', 'Transfer students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/new-transfer-students-bsi', 'High school students': 'https://www.si.umich.edu//programs/bachelor-science-information/how-do-i-apply/preferred-admissions', ... 'Exchange student information': 'https://www.si.umich.edu//programs/bachelor-science-information/exchange-student-information'}
. Since we are scraping a live site the actual values may be different.-
Write a function called
envelope_address
that takes in a parameterurl
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', '105 S State St.', 'Ann Arbor, MI 48109-1285']
. Since we are scraping a live site the actual values may be different. Write a function called
name_email
that takes in a parameterurl
, 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 to get rid of “”n n”. For example,name_email('https://www.si.umich.edu/people/directory/faculty/e')
should return{'Paul Edwards': 'pne@umich.edu', 'Ron Eglash': 'eglash@umich.edu', 'Nicole Ellison': 'enicole@umich.edu', 'Barbara Ericson': 'barbarer@umich.edu'}
.Write a function called
name_email
that takes in a parameterurl
, 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': 'pne@umich.edu', 'Ron Eglash': 'eglash@umich.edu', 'Nicole Ellison': 'enicole@umich.edu', 'Barbara Ericson': 'barbarer@umich.edu'}
.-
Write a function called
program_email
that takes in a parameterurl
, 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': 'umsi.undergrad@umich.edu', 'MSI program': 'umsi.admissions@umich.edu', 'MHI program': 'hi.admissions@umich.edu', 'MADS program': 'umsi.mads@umich.edu', 'Doctoral program': 'umsi.phd.admissions@umich.edu'}
.