我想从标记中提取名称。
如果您是一个用户,请使用以下方法:
但它正在返回:
<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>
如何获取链接的文本?
我试探着:
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>
1条答案
按热度按时间kjthegm61#
问题是,如果我从截图中没有读错的话,这个名称包含在标签中。正确的xpath是: