gpt4 book ai didi

javascript - Cheerio/NodeJS 获取div的背景图片

转载 作者:行者123 更新时间:2023-12-02 23:37:35 64 4
gpt4 key购买 nike

我正在尝试从远程页面获取 div 的背景图像。我使用 Cheerio 进行 DOM 操作,但无法像 jQuery 那样使用 css() 函数。

这是我的代码:

var $ = cheerio.load(body,{ decodeEntities: false });
console.log($(".image").css('background-image'));

我知道cheerio只是一个DOM操作符,但是有什么方法可以从页面获取background-image吗?

最佳答案

来自 Cheerio 网站的主页;强调我的:

Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure. It does not interpret the result as a web browser does. Specifically, it does not produce a visual rendering, apply CSS, load external resources, or execute JavaScript. If your use case requires any of this functionality, you should consider projects like PhantomJS or JSDom.

关于javascript - Cheerio/NodeJS 获取div的背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56221437/

64 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com