Create a gist now

Instantly share code, notes, and snippets.

@lyuehh /a.js
Created Jan 21, 2014

Embed
What would you like to do?
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));
#!/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
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment