Question: I have this python code- i have two lists with two different values - some of the values are found in both lists. i want
I have this python code- i have two lists with two different values - some of the values are found in both lists. i want to check if the values in list 1 is also in list 2. if true append them to a third list. if not append all the values of list 1 to a separate list -
current code-
from bs4 import BeautifulSoup
import requests
import sys
def courses_from_catalog(filename):
courses_from_file = courses_and_sections(filename)
courses_on_the_site_and_file = []
school_course_catalog = []
school_course_catalog_only = []
URL = ['https://catalog.endicott.edu/content.php?catoid=38&navoid=1461', 'https://catalog.endicott.edu/content.php?catoid=42&navoid=1765', 'https://catalog.endicott.edu/content.php?catoid=44&navoid=2164']
for url in URL:
response = requests.get(url , timeout = 2)
content = response.text
soup = BeautifulSoup(content , "html.parser")
courses = soup.find_all('ul' , class_="program-list")
for course in courses:
for i in course.find_all('a'):
course_text = i.text.strip()
school_course_catalog.append(course_text[:7])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
