【发布时间】:2021-08-08 08:11:06
【问题描述】:
import requests
from bs4 import BeautifulSoup
URL = 'https://www.colonialzone-dr.com/c-dominicanismos-dictionary'
page = requests.get(URL)
print("testing")
soup = BeautifulSoup(page.content, 'html.parser')
words = soup.find_all('p', class_="entry-content")
print(len(words))
for word in words:
print(word.text)
// 我的控制台上没有显示任何内容,并且长度变量返回 0,这意味着没有任何内容被抓取。
【问题讨论】:
-
该页面上没有
p标记元素与entry-content类。 -
所有单词都在 div 内的 p 标签元素中 class="entry-content" ||还是我在看东西?
-
您只能给出具有相应类/id 属性的标签。在这种情况下,
div带有标签entry-content。
标签: python html css web-scraping