0
Ich verwende den folgenden Code, um Daten zu verschrotten. Der Code scrappt jedoch nur das erste Element.Verschrotten aller Elemente mit cheerio
const cheerio = require('cheerio')
const jsonframe = require('jsonframe-cheerio')
const got = require('got');
async function scrapCoinmarketCap() {
const url = 'https://coinmarketcap.com/all/views/all/'
const html = await got(url)
const $ = cheerio.load(html.body)
jsonframe($) // initializing the plugin
let frame = {
"Coin": "td.no-wrap.currency-name > a",
"url": "td.no-wrap.currency-name > a @ href",
"Symbol": "td.text-left.col-symbol",
"Price": "td:nth-child(5) > a",
}
console.log($('body').scrape(frame, {
string: true
}))
}
scrapCoinmarketCap()
//Output -> only the first element
// {
// "Coin": "Bitcoin",
// "url": "/currencies/bitcoin/",
// "Symbol": "BTC",
// "Price": "$6122.67"
// }
Irgendwelche Vorschläge, was ich falsch mache?
Danke für Ihre Antworten!
Ich sehe nicht den Punkt, es auf diese Weise zu tun. Wenn Sie es auf die normale Weise abkratzen, können Sie es in Ihrer Browser-Konsole testen und optimieren, bis Sie es richtig verstanden haben. – pguardiario