
我想從標簽中提取名稱。
response.css('h2.product-names::text').get()
但它正在回歸:
'<h2 >
\<a target="\_blank" href="https://www.electronicsbazaar.com/dell-inspiron-13-7348-core-i5-5200u-2-20ghz-8gb-500gb-int-webcam-win-10-13-3-touch" title='Refurbished Dell Inspiron 13 7348 (Core I5 5Th Gen/8GB/500GB/Int/Win 10/13.3" Touch)'\>\\n Refurbished Dell Inspiron 13 7348 (Core I5 5Th Gen/8GB/500GB/Int/Win 10/13.3" Touch) </a>
</h2>
'
How can I get the text of the link ?
I tried:
> > > response.css('h2.product-names').get()
> > > '<h2 class="product-names">
> > >
> > > \<a target="\_blank" href="https://www.electronicsbazaar.com/dell-inspiron-13-7348-core-i5-5200u-2-20ghz-8gb-500gb-int-webcam-win-10-13-3-touch" title='Refurbished Dell Inspiron 13 7348 (Core I5 5Th Gen/8GB/500GB/Int/Win 10/13.3" Touch)'\>\\n Refurbished Dell Inspiron 13 7348 (Core I5 5Th Gen/8GB/500GB/Int/Win 10/13.3" Touch) </a>
> > >
> > > </h2>
> > >
> > > '
uj5u.com熱心網友回復:
問題是,如果我從您的螢屏截圖中正確讀取,該名稱包含在標簽中正確的 xpath 是:
response.xpath('//h2[@]/a/@title').extract()
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/453522.html
下一篇:獲取以逗號分隔的串列物件
