我正在尝试使用 NodeJS 和 Cheerio 从网站获取图像。返回的图像 URL 前面有 \n
。如何删除 \n
?
这是代码:
$("div[class=xxxx] img").attr("src")
但是 Cheerio 返回 \nhttp://www.xxxxx.com/example.jpg
我尝试使用:
var image = $("div[class=xxxx] img").attr("src").replace(\n,"")
var image = $("div[class=xxxx] img").attr("src").toString().replace(\n,"")
但是它不起作用。
最佳答案
关于javascript - 我如何删除从cheerio返回的数据中的 "\n",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41818223/