Created
November 4, 2014 12:54
-
-
Save jahil/e003d12ab84639b8bd38 to your computer and use it in GitHub Desktop.
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 requests | |
url = 'http://kitaabghar.com/bookbase/idara/KrishanChandKeBehtareenAfsanay.html' | |
def download_file(url,path,filename=''): | |
try: | |
if filename=='': | |
filename = url.split('/')[-1] | |
r = requests.get(url, stream = True,headers={'referer': 'http://kitaabghar.com/bookbase/idara/KrishanChandKeBehtareenAfsanay.html'}) | |
with open(path+ '/' + filename, 'wb') as f: | |
for chunk in r.iter_content(chunk_size=1024): | |
if chunk: # filter out keep-alive new chunks | |
f.write(chunk) | |
f.flush() | |
except Exception,e: | |
print e | |
def import_images(): | |
for i in range(1,80): | |
import_page.apply_async([i]) | |
pass | |
for i in range(200): | |
download_file('http://kitaabghar.com/bookbase/idara/krishanchand.php?image=krishanchandafsanay-%s.gif' %i ,'.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment