Advertisement
Guest User

Bartkira.py

a guest
Jun 28th, 2014
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Rename to Bartkira.py
  2. # python Bartkira.py
  3. # Wait ...
  4.  
  5. import urllib2
  6. import time
  7.  
  8. images = []
  9. base_url = "http://www.bartkira.com/uploads/"
  10. source = urllib2.urlopen("http://www.bartkira.com/volume-1.html")
  11. for line in source.readlines():
  12.     if "wSlideshow.render" in line:
  13.         loc = -1
  14.         while True:
  15.             loc = line.find("1/0", loc + 1)
  16.             if loc != -1:
  17.                 end = line.find(".", loc) + 4
  18.                 image_url = base_url + line[loc:end].replace(".", "_orig.")
  19.                 images.append(image_url)
  20.             else:
  21.                 break
  22.  
  23. index = 0
  24.  
  25. for image in images:
  26.     print image
  27.     image_type = ".jpg"
  28.     if ".jpg" in image:
  29.         image_type = ".jpg"
  30.     if ".png" in image:
  31.         image_type = ".png"
  32.    
  33.     imagefile = urllib2.urlopen(image)
  34.    
  35.     page_name = "Bartkira_" + str(index+1).zfill(3) + image_type
  36.     output = open(page_name,'wb')
  37.     output.write(imagefile.read())
  38.     output.close()
  39.     time.sleep(1)
  40.     index += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement