简体   繁体   中英

How to scrape data from website with cheerio

I am trying to scrape the Ark: Survival Evolved wiki with no success. Nested elements and same class-name elements throwing me off. https://ark.gamepedia.com/Pteranodon

Have tried searching the forums and cannot find the answer to my problem.

const $ = cheerio.load(html);
const $dossier = $('.info-framework');
const $domestication = $dossier.find('div:nth-child(4)');

i manage to grab the div that contains the content i need, but everything i try from here ends in undefined. specifically i am trying to grab the "tameable", "rideable" & "breedable" elements. If someone could point me in the right direction, or show me how to grab the data so i could then learn and hopefully grab the rest of the data i need that would be great.

Here some example you can build up on:

 const abilities = Array.from($('.info-unit').eq(6).find('.info-X3-33')).map(element => element.innerText) 

EDIT: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM