Advertisement
Guest User

Bartkira Vol.3

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