The problem is there is a button saying "SHOW MORE" on the webpage...because of that the script can't access all the courses .... from bs4 import BeautifulSoup import requests
res = requests.get('https://www.coursera.org/specializations/digital-manufacturing-design-
technology#courses')
txt = res.text
status = res.status_code
#print(txt)
#print(status)## 200 is the code for success
page = requests.get('https://www.coursera.org/specializations/digital-manufacturing-design-
technology#courses')
soup = BeautifulSoup(page.content,'lxml')
#Display the title of the specialisation
specialization_title = soup.find('h1')
print(specialization_title.text)
print("\n")
#Display the courses inside the specialisation
number_of_courses = soup.find('h2',class_ = 'headline-4-text bold m-b-1')
print(number_of_courses.text)
print("\n")
course_cards = soup.find_all('h3',class_= 'headline-3-text bold m-t-1 m-b-2')
for course in course_cards:
print(course.text)
Aucun commentaire:
Enregistrer un commentaire