Simple book downloader for e-libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pyelibdownloader.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import wget, os
  4. print ("pyElibDownloader")
  5. promptprefix = ("Enter prefix of download URL (default [http://elib.shpl.ru/pages/]): ")
  6. prefix = input (promptprefix)
  7. if prefix == "":
  8. prefix = ("http://elib.shpl.ru/pages/")
  9. promptpostfix = ("Enter postfix of download URL (default [/zooms/7]): ")
  10. postfix = input (promptpostfix)
  11. if postfix == "":
  12. postfix = ("/zooms/7")
  13. promptextension = ("Enter files extension (default [jpg]): ")
  14. extension = input (promptextension)
  15. if extension == "":
  16. extension = ("jpg")
  17. promptdir = ("Enter directory name: ")
  18. dir = ""
  19. while dir == "":
  20. dir = input (promptdir)
  21. promptfirstindex = ("Enter first index: ")
  22. firstindex = ""
  23. while firstindex == "":
  24. firstindex = input (promptfirstindex)
  25. promptlastindex = ("Enter last index: ")
  26. lastindex = ""
  27. while lastindex == "":
  28. lastindex = input (promptlastindex)
  29. print ("Starting donwload...")
  30. try:
  31. os.stat(dir)
  32. except:
  33. os.mkdir(dir)
  34. os.chdir(dir)
  35. index = int(firstindex)
  36. lastindex = int(lastindex)
  37. while index <= lastindex:
  38. filename = str(index) + "." + extension
  39. url = prefix + str(index) + postfix
  40. try:
  41. wget.download(url,out=filename)
  42. except:
  43. print ("...skipped...")
  44. index = index + 1
  45. print ("Donwload finished.")