我正在努力创建一个数据框架,但目前的作品,因为它废弃了网站的标题和课程。现在我正在努力写一些函数使用数据框架,将从网站计数为多少网址链接。此后,必须从网站翻译这些文本上下文(英语到印地语)。任何人谁可以帮助我这个问题?
`# scrapping of the class-central.com website links
# this application uses selinium driver to access the web-pages
#
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
url = "https://www.classcentral.com/collection/top-free-online-courses"
driver = webdriver.Chrome()
driver.get(url)
time.sleep(2)
all_courses = driver.find_element(by=By.CLASS_NAME, value='catalog-grid__results')
course_titles = all_courses .find_elements(by=By.CSS_SELECTOR, value='[class="color-charcoal course-name"]')
for title in course_titles:
print(title.text)
`
1条答案
按热度按时间nc1teljy1#
我不确定我理解的是否正确,但如果你想加载所有课程,你必须点击"加载更多"直到按钮不可用。你可以通过
href
属性获得课程的URL:输出: