Skip to content

Instantly share code, notes, and snippets.

@oflow
Last active May 5, 2017 11:59
Show Gist options
  • Save oflow/26934d3d4cd598282d0a45e4548099bd to your computer and use it in GitHub Desktop.
Save oflow/26934d3d4cd598282d0a45e4548099bd to your computer and use it in GitHub Desktop.
egid
'use strict';
var client = require('cheerio-httpcli'),
fs = require('fs'),
co = require('co'),
ev = '',
act = 3;
client.setBrowser('chrome');
co(function*() {
var json = [];
for (let i = 580; i < 620; i++) {
let res = yield getEgid(i);
json.push(res);
}
console.log(json);
});
function getEgid(id) {
var url = ev + '?act=' + act + '&egid=' + id;
return client.fetch(url).then(res => {
let $ = res.$,
title = $('#contents .eventmaintitle').text(),
date = $('#contents .detail').first().text().replace(/[ \r\n\t]+/g, ''),
err = /File not found/.test($('#comment-area').text());
return {'title': title, 'date': date, 'url': url, 'error': err};
}).catch(res => {
return res;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment