Created
September 5, 2014 20:27
-
-
Save avnik/7b1771a788a5b1d95c76 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/python | |
| from urllib2 import urlopen | |
| import os,sys,re | |
| from BeautifulSoup import BeautifulSoup | |
| if not len(sys.argv) == 2: | |
| print "usage: %s <url>" % (sys.argv[0]) | |
| sys.exit(1) | |
| lib = sys.argv[1] | |
| page = urlopen(lib) | |
| page = BeautifulSoup(page) | |
| fb2 = re.compile('.*\.fb2\.zip$') | |
| for each in page.findAll('a'): | |
| url = each['href'] | |
| if url.startswith(lib): | |
| book = urlopen(url) | |
| book = BeautifulSoup(book) | |
| for bookurl in book.findAll('a'): | |
| href = bookurl['href'] | |
| if fb2.search(href) and href.startswith(lib): | |
| print href | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment