Skip to content

Instantly share code, notes, and snippets.

@jahil
Created November 4, 2014 12:54
Show Gist options
  • Save jahil/e003d12ab84639b8bd38 to your computer and use it in GitHub Desktop.
Save jahil/e003d12ab84639b8bd38 to your computer and use it in GitHub Desktop.
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