Skip to content

Instantly share code, notes, and snippets.

@avnik
Created September 5, 2014 20:27
Show Gist options
  • Save avnik/7b1771a788a5b1d95c76 to your computer and use it in GitHub Desktop.
Save avnik/7b1771a788a5b1d95c76 to your computer and use it in GitHub Desktop.
#!/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