Skip to content

Instantly share code, notes, and snippets.

@kami4ka
Created March 22, 2022 19:07
Show Gist options
  • Save kami4ka/f947fc538dfe0eb514285bc9aef5f6dd to your computer and use it in GitHub Desktop.
Save kami4ka/f947fc538dfe0eb514285bc9aef5f6dd to your computer and use it in GitHub Desktop.
ra.co promoters scraper
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