Css 选择器在 img Cheerio 中采用特定的 src
Css selector take a spesific src in img Cheerio
我不知道如何获取特定的 src
const img1 = selector
.find("li.gallery_thumbItem.s-gallery_thumbItem:nth-child(3) span.gallery_thumbIn> img:last-child")
.attr("src");
此 html 页:
但只想从 html 获取第一张 img,这是我抓取的结果,
其实我只是想拿这个
考虑以下几点:
const img1 = selector.find(".gallery_thumbItem.s-gallery_thumbItem:nth-child(3) img[src$='.jpg']:last").attr("src");
由于其他是 .gif
图片,它会忽略那些。过滤掉这些后,您将只有 .jpg
项。
我不知道如何获取特定的 src
const img1 = selector
.find("li.gallery_thumbItem.s-gallery_thumbItem:nth-child(3) span.gallery_thumbIn> img:last-child")
.attr("src");
此 html 页:
但只想从 html 获取第一张 img,这是我抓取的结果,
其实我只是想拿这个
考虑以下几点:
const img1 = selector.find(".gallery_thumbItem.s-gallery_thumbItem:nth-child(3) img[src$='.jpg']:last").attr("src");
由于其他是 .gif
图片,它会忽略那些。过滤掉这些后,您将只有 .jpg
项。