Question: Convert the code below so that it only uses the modules: import re import webbrowser import urllib.request, ssl to accomplish output results instead of using

Convert the code below so that it only uses the modules:

import re import webbrowser import urllib.request, ssl

to accomplish output results instead of using the module "BeautifulSoup" to do so.

- You cannot use BeautifulSoup

-Use regular expressions

Question 1: Retrieve the correct course list, with both number and title (parsing)

question 2: Ask User to enter a word to search for - Displays only the courses with the given word.

__________________________________

from bs4 import BeautifulSoup import requests import re

#request page link page_link ='https://www.sice.indiana.edu/undergraduate/courses/index.html'

#get request and gain the response page_response = requests.get(page_link, timeout=5)

#buitifying the response html content page_content = BeautifulSoup(page_response.content, "html.parser")

#getting the courses class main = page_content.find_all(class_='parent clearfix')

main="".join(str(x) for x in main)

#beutifying to get all the courses anchor tags main=BeautifulSoup(main,"html.parser")

courses = main.find_all('a', href=True)

#get each course name courses_list=[] for a in courses: courses_list.append(a.text)

search=input("Enter the course words you looking for: ") for course in courses_list: if re.search(search, course, re.IGNORECASE): print(course)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!