I am using Scrapy
to crawl data.
On JS
console on my browser, I type $x('//div[@class="summary"]//div[contains(@class, "tags")]')
to get what I need, but I need to filter the data.
The following picture is the $x('//div[@class="summary"]//div[contains(@class, "tags")]')
command result.
How should I write xpath
command to get the data in the green box? I tried $x('//div[@class="summary"]//div[contains(@class, "tags")]//a[contains(@class, "post-tag")]')
, but that is not what I want。
Thank you!
要在所选div
选择<a>
元素的内部文本,您只需要将/a/text()
附加到选择div
XPath:
//div[@class="summary"]//div[contains(@class, "tags")]/a/text()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.