Created
February 9, 2012 22:01
-
-
Save alaingilbert/1783647 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, urllib, re, sys | |
def main(): | |
if not len(sys.argv) > 1: | |
print "You shall give a genre. example: python band.py house" | |
return | |
keyword = sys.argv[1] | |
res = [] | |
html = urllib2.urlopen('http://www.bandnamemaker.com/generator/?cw=%s' % keyword).read() | |
li = re.search('<ul id="generator-results">(.+)</ul>', html, re.DOTALL) | |
if li: | |
li = li.group(1).replace('\n', '') | |
res = re.findall('<li>(.+?)</li>', li) | |
print res | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment