1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
import requests
import os
def geturl1(i,j): return ('''http://****.com/media/_10b76617/assets/girls/girl_{0:0>2}/images/image{1}n.jpg''').format(i,j)
def geturl1s(i,j): return ('''http://****.com/media/_10b76617/assets/girls/girl_{0:0>2}/images/sex-{1}.jpg''').format(i,j)
rootpath = 'E:\\pictures\\'
for i in range(6,13): if not os.path.isdir(rootpath+'1s\\'+'{:0>2}'.format(i)+'\\'): os.mkdir(rootpath+'1s\\'+'{:0>2}'.format(i)+'\\') for j in range(1,6): fname = rootpath+'1s\\'+'{:0>2}'.format(i)+'\\'+'{:0>2}'.format(j)+'.jpg' print fname fout = open(fname,'wb') while True: try: pic= requests.get(geturl1s(i,j), timeout=10) except requests.exceptions.ConnectionError: print 'error:current picture cannot be downloaded' continue break fout.write(pic.content) fout.close()
for i in range(1,13): if not os.path.isdir(rootpath+'1\\'+'{:0>2}'.format(i)+'\\'): os.mkdir(rootpath+'1\\'+'{:0>2}'.format(i)+'\\') for j in range(1,11): fname = rootpath+'1\\'+'{:0>2}'.format(i)+'\\'+'{:0>2}'.format(j)+'.jpg' print fname fout = open(fname,'wb') while True: try: pic = requests.get(geturl1(i,j), timeout=10) except requests.exceptions.ConnectionError: print 'error:current picture cannot be downloaded' continue break fout.write(pic.content) fout.close()
|