Skip to content

Instantly share code, notes, and snippets.

@JBKahn
Last active August 29, 2015 14:03
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 JBKahn/dba6c75425cabc94aafb to your computer and use it in GitHub Desktop.
Save JBKahn/dba6c75425cabc94aafb to your computer and use it in GitHub Desktop.
Street Fighter
import random
import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
wiki_page = "http://streetfighter.wikia.com/wiki/List_of_moves_in_Street_Fighter_II"
r = requests.get(wiki_page)
soup = BeautifulSoup(r.content)
games = soup.find_all("tr")
while True:
choice = random.choice(games)
move = choice.getText().split('\n')[1]
if move == u'Move Name':
continue
character = choice.find_parent('table').findPreviousSibling('h2').text.replace('Edit', '')
if move.lower().find('super combo') > -1:
link = "http://streetfighter.wikia.com" + choice.find_all('a')[1].get('href')
else:
link = "http://streetfighter.wikia.com" + choice.find_next('a').get('href')
print "{}: {} ({})".format(character, move, link)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment