Created
March 22, 2022 19:07
-
-
Save kami4ka/f947fc538dfe0eb514285bc9aef5f6dd to your computer and use it in GitHub Desktop.
ra.co promoters scraper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio'); | |
const ScrapingAnt = require('@scrapingant/scrapingant-client'); | |
const API_KEY = '<YOUR_SCRAPINGANT_API_KEY>'; | |
const URL_TO_SCRAPE = 'https://ra.co/events/1479360'; | |
const BASE_URL = 'https://ra.co'; | |
const client = new ScrapingAnt({ apiKey: API_KEY }); | |
main() | |
.then(console.log) | |
.catch(console.error); | |
async function main() { | |
const response = await client.scrape(URL_TO_SCRAPE, {wait_for_selector: 'ul.grid'}); | |
const $ = cheerio.load(response.content); | |
const promotersUrls = []; | |
const anchors = $('a'); | |
anchors.each((index, element) => { | |
let link = $(element).attr('href'); | |
if (link && link.includes('/promoters')) { | |
link = link.replace(BASE_URL, ''); | |
promotersUrls.push(link); | |
} | |
}); | |
return promotersUrls; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment