Skip to content

Instantly share code, notes, and snippets.

@VMuliadi
Last active March 16, 2017 13:43
Show Gist options
  • Save VMuliadi/9719af1e8d3bb400690f27b6614cc3ca to your computer and use it in GitHub Desktop.
Save VMuliadi/9719af1e8d3bb400690f27b6614cc3ca to your computer and use it in GitHub Desktop.
Bulk downloader from allitebooks.com - Use wisely
import re, wget, urllib2, sys
from bs4 import BeautifulSoup
booklist = []
base_url = 'http://www.allitebooks.com/'
for index, book_title in enumerate(sys.argv) :
if index > 0 : booklist.append(book_title)
for index, booktitle in enumerate(booklist, 1) :
stringified_book = re.sub('[^a-zA-Z0-9 \-\\n\.]', '', booktitle.lower()).replace(' ','-')
try : # try to download the book using wget
page = urllib2.urlopen(base_url + stringified_book)
soup = BeautifulSoup(page,'lxml')
link = soup.find('a',{'target':'_blank'}).get('href')
filename = link.split('/')[len(link.split('/'))-1]
print 'Downloading %s - %s/%s' % (booktitle, str(index), str(len(booklist)))
wget.download('%s' % link)
except urllib2.HTTPError : print 'Book not found'
@VMuliadi
Copy link
Author

VMuliadi commented Mar 16, 2017

How to Use?

python allitebooks.py '<Book Name 1>' '<Book Name 2>'
example : python allitebooks.py 'Virtual Reality Headsets'
example : python Downloader.py 'Java EE 7 Development with NetBeans 8' 'Java SOA Cookbook' 'Java EE 7 Developer Handbook'

Output Program

Downloading Virtual Reality Headsets - 1/1 100% [......................................................] 6778974 / 6778974

Downloading Java EE 7 Development with NetBeans 8 - 1/3 100% [....................................................] 23828334 / 23828334 Downloading Java SOA Cookbook - 2/3 100% [....................................................] 10486218 / 10486218 Downloading Java EE 7 Developer Handbook - 3/3 100% [......................................................] 8656848 / 8656848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment