#!/bin/sh
for i in `seq 2003 2014`
do
u="http://www.3dcp.cn/zs/gonggao.php?type=ssq&year=$i"
echo $u
curl -s $u | iconv -f gbk -t utf8 | hquery -p -r '$("table").eq(13).parent().html()' > $i.html
done
#!/bin/sh
for i in `seq 2003 2014`
do
echo $i
cat ${i}.html | hquery -p -f a.js | sed '$d' > json/${i}.json
done
a = _.reduce($("tr"), function(memo, v, i) {
var $el = $(v);
var obj = {};
obj.id = $.trim($el.find('.end').text());
obj.date = $el.find('td').eq(1).text();
obj.red = $el.find('.STYLE13').html() && $el.find('.STYLE13').html().replace(/ /g, ' ');
obj.blue = $el.find('.STYLE12').text();
if (obj.id !== '') {
memo.push(obj);
}
return memo;
}, []);
console.log(JSON.stringify(a, null, 2));