xpath meta itemProp标签无法匹配到的问题

部分html代码如下

'''
<div class="QuestionPage" itemscope="" itemType="http://schema.org/Question">
<meta itemProp="name" content="\u96fe\u973e\u771f\u7684\u89e3\u51b3\u4e0d\u4e86\u4e48\uff1f"/>
<meta itemProp="url" content="https://www.zhihu.com/question/22863429"/>
<meta itemProp="keywords" content="\u5317\u4eac,\u73af\u5883\u4fdd\u62a4,\u7a7a\u6c14\u8d28\u91cf,PM 2.5"/>
<meta itemProp="answerCount" content="841"/><meta itemProp="commentCount" content="57"/>
<meta itemProp="dateCreated" content=""/>
'''

我的xpath表达式如下

tree.xpath('//meta[itemProp="keywords"]/@content')

无法匹配到结果

但是使用

tree.xpath('//meta/@content')

可以匹配到所有的meta标签结果

结果中含有目标字段内容

暂未解决该问题,在此记录


已解决

解决方案如下,改itemProp 为 itemprop

tree.xpath('//meta[@itemprop="keywords"]/@content')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值