如何使用css选择器获取href链接

时间:2017-08-04 23:17:59

标签: css-selectors scrapy-spider

我正在尝试让抓取工具在imgur上抓取图片。我在选择要选择的元素时遇到问题。我试图在主页上为每个图像选择href链接。主页是:https://imgur.com/t/memes/ 如果有人知道正确的css选择器来获得每个图像的特定href链接那将是伟大的!

为了进一步说明,我需要选择href中的链接:here is the html code。有谁知道我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

这应该做:

a.Grid-item::attr(href)

击穿:

a - 选择节点。
.Grid-item - 有类"网格项"。
::attr(href) - 选择当前节点的属性href。

相关问题