以下是我的节点js代码
request(options, function(error, response, body) {
console.log(body);
});
如果我是console.log('body'),我将从此请求中获取所有html代码,但是,如果我只想要一些代码,我该怎么办?
例如,我只想在id为“test”的div下使用html?
我能这样做吗?
答案 0 :(得分:1)
您可以尝试使用Cheerio解析和遍历HTML代码:https://cheerio.js.org/
答案 1 :(得分:0)
查看XPath并使用它来帮助您找到特定的div。 https://www.w3schools.com/xml/xpath_intro.asp