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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started