我只想从这个特殊的div
访问文本。
结构如下:
<div class="edgtf-pli-text"><h4 class="edgtf-pli-title entry-title" itemprop="name">
Crash Landing on You</h4></div>
代码是:
import requests
from bs4 import BeautifulSoup
page = requests.get('https://kdramaclicks.com/kdrama/romantic-comedy/')
soup = BeautifulSoup(page.content,'html.parser')
names = soup.find_all('div',class_='edgtf-pli-text')
print(names)
我如何塑造代码,使其只显示文本,即“坠机降落在你身上?”
我真的是一个新手,所以请帮我一点忙,如果有什么好的api用于抓取wiki表,也推荐我一个
输出:
使用^{} 方法提取标记内的文本
您可以使用BeautifulSoup标记的
.text
属性,然后使用.strip()
属性(删除每个韩剧名称中前面的“\n”(新行字符)相关问题 更多 >
编程相关推荐