diff options
author | emkael <emkael@tlen.pl> | 2017-09-07 02:10:36 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-09-07 02:10:36 +0200 |
commit | 4060fa99c23bca17895029ae1ffad24d0d024269 (patch) | |
tree | cf4f322e236d913e238366a2de30727d0d2561cb /scripts/ranking.py | |
parent | 26f2934bcdfec9b32131ec01bbdd493146b3ad57 (diff) |
Moving *.py scripts to separate directory, cleaning things up
Diffstat (limited to 'scripts/ranking.py')
-rw-r--r-- | scripts/ranking.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/ranking.py b/scripts/ranking.py new file mode 100644 index 0000000..4a16867 --- /dev/null +++ b/scripts/ranking.py @@ -0,0 +1,21 @@ +import os, sys +from bs4 import BeautifulSoup as bs4 + +ranking_date = sys.argv[3] +subtitle = 'notowanie %s (%s), stan na %s' % ( + sys.argv[1], sys.argv[2], '.'.join(ranking_date.split('-')[::-1]) +) + +table = bs4(file('templates/ranking.html'), 'lxml') +table.select('.page-header h2 small')[0].string = subtitle + +table.select('table.data-table')[0]['data-ranking'] = 'data/%s.json' % ( + ranking_date) + +script_src = table.select('script[src="res/ranking.js"]')[0] +script_src['src'] = '%s?%d' % ('res/ranking.js', os.path.getmtime('http/res/ranking.js')) + +rawlink = table.select('a#rawlink')[0] +rawlink['href'] = '%s/%s.csv' % (rawlink['href'], ranking_date) + +print table.prettify().encode('utf-8') |