Python 使用css选择器在抓取中提取跨度外的文本
我有以下html代码:Python 使用css选择器在抓取中提取跨度外的文本,python,html,scrapy,css-selectors,scrapy-spider,Python,Html,Scrapy,Css Selectors,Scrapy Spider,我有以下html代码: <h1> <a href="https://www.google.com"> <span>448587: </span>Brian McMills </a> </h1> 我只对布莱恩·麦克米尔斯感兴趣。我想使用scrapycss选择器功能来选择文本 当我使用h1a::text时,它只选择448587:部分,我尝试了:not(
<h1>
<a href="https://www.google.com">
<span>448587: </span>Brian McMills
</a>
</h1>
我只对布莱恩·麦克米尔斯感兴趣。我想使用scrapycss选择器
功能来选择文本
当我使用h1a::text
时,它只选择448587:
部分,我尝试了:not(span)
的一些组合,但它不起作用
注意:我对
Xpath
或scripting
解决方案不感兴趣,只有css
唯一有效的方法是h1a:not(span)::text
谢谢。试着看看这里h1a:不(span)
必须工作。你试过用这种方式写吗?我必须添加h1a:not(span)::text
才能使它工作。谢谢