啥也不说了,直接上代码
import numpy as np
import requests as req
from PIL import Image
import urllib.request
def process(string):
temp = str.split(string,',')
this_url = temp[1]
name = temp[0]
while name[0] == '0':
name = name[1:]
print('Processing: ',name )
resource =urllib.request.urlopen(this_url,timeout=10)
output = open('/raid/Guests/DaYea/another_image_dataset/img/'+name+'.jpg',"wb")
output.write(resource.read())
output.close()
count = 0
f=open(r'/raid/Guests/DaYea/another_image_dataset/info/photos.txt')
while True:
count = count + 1
line=f.readline()
if not line:break
if count >= 20000: #18896
process(line)
f.close()