python - 如何使用 PyQuery 从元标记获取内容值?

标签 python pyquery

<meta name="keywords" content="Ruby On Rails (Software), Authentication (Software Genre), Tutorial (Industry), howto, tips, tricks">

如何使用 PyQuery 从此元标记获取 content 值?

from pyquery import PyQuery

def get_data(myurl):
    query = PyQuery(url=myurl)
    title = query("title").text()
    keyword = query("meta[name=keywords]").text()
    ...

最佳答案

你几乎已经成功了,缺少设置keywork的撇号字符

keyword = query("meta[name='keywords']").text()

关于python - 如何使用 PyQuery 从元标记获取内容值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20382578/

相关文章:

python - pip 错误 : unrecognized command line option ‘-fstack-protector-strong’

Python/PyQuery : Unable to find vcvarsall. bat ?

python - PyQuery:只获取元素的文本,而不是子元素的文本

web-crawler - 从文章中提取作者

python - 如何在pyquery中获取单个css样式

python - 使用递归的列表列表

python - 如何在 after_request 函数中更改 flask 中的响应?

python - optparse 描述中的 ASCII 艺术

python - 将字符串拆分为多个可能更改的变量

python - 是否可以像在 GUI 中一样通过 Excel 公式填写整个列? #gspread