- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
/**
* Peetushna
* Node.js 10
* node index.js > report.csv
*/
const { get } = require("axios");
const { load } = require("cheerio");
Promise.resolve().then(async () => {
const responses = reqGen(1, 25000);
const peetushna = /питушня/g;
for await (const resp of responses) {
if (resp.status != 200) break;
const wordCount = resp.data.match(peetushna);
const count = wordCount ? wordCount.length : 0;
const html = load(resp.data);
const lang = html('a[rel="chapter"]')
.text()
.replace("Си", "C");
console.log(`"${lang}", ${count}`);
}
});
async function* reqGen(first, max) {
while (first <= max) {
try {
const resp = await get("http://govnokod.ru/" + first++);
yield resp;
} catch (e) {
//
}
}
}
Steve_Brown 28.04.2018 17:23 # +1
1024-- 28.04.2018 18:16 # +1
Вообще, для блоков try-catch в языках должны быть сразу предусмотрены варианты:
1. try {} catch (e) {}
2. try {} catch {}
3. try {} catch;
4. exec {} // exec { xxx } аналогично try { xxx } catch (e) {}
mazhuravlev 28.04.2018 18:54 # 0
roskomgovno 29.04.2018 04:02 # +1
mazhuravlev 28.04.2018 18:52 # 0
bormand 29.04.2018 13:44 # +1