I want to get the rows of this site with cheerio, but because the site needs to be loaded, it only shows me the first 10 rows. How can I get all rows of this table? coinmarketcap.com
在这个网站上,第一页的桌子有100 rows个.我需要获取所有这100 rows个的信息,但我编写的这段代码只给出了first 10个.因为当我加载站点时,它在第一时刻只显示前10个,其余的被加载然后显示.
const express = require("express");
const axios = require("axios");
const cheerio = require("cheerio");
let PORT = 8000;
let links = "https://coinmarketcap.com";
const app = express();
axios.get(link).then((response) => {
const html = response.data;
const $ = cheerio.load(html);
$(".coin-logo").each(function (i) {
console.log($(this).attr("src"), i);
});
});
app.listen(PORT, () => console.log(`server is running on PORT: ${PORT}`));
在控制台中
server is running on PORT: 8000
https://s2.coinmarketcap.com/static/img/coins/64x64/1.png 0
https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png 1
https://s2.coinmarketcap.com/static/img/coins/64x64/825.png 2
https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png 3
https://s2.coinmarketcap.com/static/img/coins/64x64/3408.png 4
https://s2.coinmarketcap.com/static/img/coins/64x64/52.png 5
https://s2.coinmarketcap.com/static/img/coins/64x64/2010.png 6
https://s2.coinmarketcap.com/static/img/coins/64x64/3890.png 7
https://s2.coinmarketcap.com/static/img/coins/64x64/74.png 8
https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png 9
Returns only the first ten rows. While the table has 100 rows.