Created
March 29, 2014 22:39
-
-
Save patrykorwat/9864205 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from BeautifulSoup import BeautifulSoup | |
| import re, Image | |
| for tr in BeautifulSoup(open('index.html', 'r')).findAll(lambda tag: (tag.name == 'tr' and tag.td and tag.td.attrs and len(tag.td.attrs) ==1) and tag.td.p): | |
| print "INSERT INTO colour (`palette_id`,`photo`,`name`) VALUES (11,'"+re.sub(r'\#+', '', tr.contents[5].span.string)+".jpg','"+re.sub(r' *\n *', ' ', tr.td.p.span.string.replace(' ',' '))+'-'+re.sub(r' *\n *', ' ', tr.contents[9].p.span.string.replace(' ',' '))+"'); " | |
| Image.new('RGB',(29,29), tr.contents[5].span.string.replace('##','#')).save(re.sub(r'\#+', '', tr.contents[5].span.string)+'.jpg', 'JPEG') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment