-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscrape_vow.js
More file actions
26 lines (22 loc) · 986 Bytes
/
Copy pathscrape_vow.js
File metadata and controls
26 lines (22 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const puppeteer = require('puppeteer');
const cheerio = require('cheerio');
(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://offene-werkstaetten.org/en/workshop-search', { waitUntil: 'networkidle2' });
const html = await page.content();
const $ = cheerio.load(html);
const workshops = [];
$('#workshops-wrapper > div').each((i, el) => {
workshops.push({
index: i + 1,
name: $(el).find('a.workshop-name').text().trim(),
profileUrl: 'https://offene-werkstaetten.org' + $(el).find('a.workshop-name').attr('href'),
address: $(el).find('p.address').clone().find('a').remove().end().text().trim(),
website: $(el).find('p.address a').attr('href') || null,
categories: $(el).find('.categories-wrapper img').map((_, img) => $(img).attr('title')).get()
});
});
console.log(JSON.stringify(workshops, null, 2));
await browser.close();
})();