Last active
March 16, 2017 13:43
-
-
Save VMuliadi/9719af1e8d3bb400690f27b6614cc3ca to your computer and use it in GitHub Desktop.
Bulk downloader from allitebooks.com - Use wisely
This file contains 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 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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