Last active
May 5, 2017 11:59
-
-
Save oflow/26934d3d4cd598282d0a45e4548099bd to your computer and use it in GitHub Desktop.
egid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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