Created
August 30, 2012 12:10
-
-
Save kgleeson/3527319 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
| import urllib2 | |
| import re | |
| url = 'http://wiki.shoryuken.com/index.php?title=Super_Street_Fighter_IV_AE/Abel&action=edit' | |
| def test(url): | |
| data = read_url_data(url) | |
| table = find_move_table(data) | |
| print find_moves_data(table) | |
| def read_url_data(url): | |
| f = urllib2.urlopen(url) | |
| return f.read() | |
| def find_move_table(data): | |
| movesRE = re.compile('==Frame Data==(.+)=====Notes:=====', re.DOTALL) | |
| return movesRE.findall(data)[0] | |
| def find_moves_data(data): | |
| regex = re.compile(r'''\|-\ \n | |
| \|.+?\|(?P<Move>.+?)\n | |
| \|.+?\|(?P<HL>.+?)\n | |
| \|.+?\|(?P<Damage>.+?)\n | |
| \|.+?\|(?P<Stun>.+?)\n | |
| \|.+?\|(?P<Gain>.+?)\n | |
| \|.+?\|(?P<Cancel>.+?)\n | |
| \|.+?\|(?P<Startup>.+?)\n | |
| \|.+?\|(?P<Active>.+?)\n | |
| \|.+?\|(?P<Recovery>.+?)\n | |
| \|.+?\|(?P<Block>.+?)\n | |
| \|.+?\|(?P<Hit>.+?)\n | |
| (?:|\|.+?\|(?P<Notes>.+?)\n) | |
| ''',re.DOTALL|re.VERBOSE) | |
| return regex.search(data).groupdict() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment