Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created January 21, 2014 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyuehh/8537324 to your computer and use it in GitHub Desktop.
Save lyuehh/8537324 to your computer and use it in GitHub Desktop.
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