【发布时间】:2022-01-19 20:05:57
【问题描述】:
I want to get both of names "Justin Cutroni" and "Krista Seiden" without the tags
这是我想通过python3获取名称的html代码:
我使用了beautifulsoup,但我不知道如何深入了解 html 代码并获取名称。
import requests
from bs4 import BeautifulSoup as bs
web_pages = ["https://maktabkhooneh.org/learn/"]
def find_lessons(web_page):
# Load the webpage content
r = requests.get(web_page)
# Convert to a beautiful soup object
soup = bs(r.content, features="html.parser")
table = soup.select('div[class="course-card__title"]')
data = [x.text.split(';')[-1].strip() for x in table]
return data
find_teachers(web_pages[0])
【问题讨论】:
-
使用开发者工具并找到 XPath。
标签: python html css beautifulsoup