任何有 axios/cheerio 经验的人都可以回答这个问题吗?我正在尝试制作一个刮板,但很难让它被选中divhtml部分是这样的:<div class="_702d723c dib w-50 bb b--black-10 pr2"><h3 class="c84e15be f5 mt2 pt2 mb0 black-50">Version</h3><p class="f2874b88 fw6 mb3 mt2 truncate black-80 f4">7.3.2</p></div>刮板代码:const cheerio = require("cheerio");const axios = require("axios");let NPMJS = `https://www.npmjs.com/package/semver`;axios.get(NPMJS).then((response) => { let $ = cheerio.load(response.data); $('._702d723c').filter(function () { var data = $(this); let version = data.children().first().next().text() console.log(version) })}).catch(function (e) { console.log(e);});输出:7.3.2ISC83.8 kB51github.com/npm/node-semver#readmeGitgithub.com/npm/node-semver6 months ago我如何从这个输出中得到7.2.3?
添加回答
举报
0/150
提交
取消