【问题标题】:BeautifulSoup get only content textBeautifulSoup 仅获取内容文本
【发布时间】:2021-03-28 20:17:25
【问题描述】:

我是 python 和 BeautifulSoap 的新手。我这样实现我的刮刀:

title_attr = soup.find("meta", {"name": "description"})

而 print(title_attr) 是这样的:

<meta content="I want to only this text. How can I make this?" name="description"/>

但我只想获取内容文本。 我该怎么做?

【问题讨论】:

  • title_attr["content"]

标签: python python-3.x beautifulsoup


【解决方案1】:

在查找表达式的末尾包含 .text。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-14
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-02
    相关资源
    最近更新 更多