1
2
3
4const Apify = require('apify');
5
6Apify.main(async () => {
7
8
9 const input = await Apify.getInput();
10 console.log('Input:');
11 console.dir(input);
12
13
14
15 const metamorphInput = {
16 "startUrls": [
17 {
18 "url": "https://prazdnedomy.cz/domy/objekty/?paginator-page=1",
19 "method": "GET"
20 }
21 ],
22 "useRequestQueue": true,
23 "pseudoUrls": [
24 {
25 "purl": "https://prazdnedomy.cz/domy/objekty/?paginator-page=[\\d+]",
26 "method": "GET"
27 }
28 ],
29 "linkSelector": "a",
30 "pageFunction": "async function pageFunction(context) {\n const { request, $ } = context;\n let result = [];\n $('.estates-list .estate').each(function(i) {\n let typ = null;\n let stav = null;\n let gps = null;\n let adresa = null;\n\n $(this).find('.icons .icon').each(function() {\n const maybeHtml = $(this).attr('title')\n if (!maybeHtml) return\n const maybeTyp = maybeHtml.match(/<td>Typ: <\\/td><td>(.+?)<\\/td>/)\n if (maybeTyp) {\n typ = maybeTyp[1]\n }\n const maybeStav = maybeHtml.match(/<td>Stav: <\\/td><td>(.+)<\\/td>/)\n if (maybeStav) {\n stav = maybeStav[1]\n return\n }\n \n const maybeGps = maybeHtml.match(/\\d+°.+''/)\n if (maybeGps) {\n gps = maybeGps[0]\n adresa = maybeHtml.replace(gps, '')\n }\n \n })\n\n result.push({\n title: $(this).find('.content .title').text().trim(),\n url: 'https://prazdnedomy.cz' + $(this).find('a').attr('href'),\n typ,\n stav,\n gps,\n adresa,\n })\n })\n return result;\n}",
31 "proxyConfiguration": {
32 "useApifyProxy": false
33 },
34 "debugLog": false,
35 "ignoreSslErrors": false,
36 "useCookieJar": false
37 };
38
39
40 await Apify.metamorph('apify/cheerio-scraper', metamorphInput);
41});