爬t1

import requests
import webbrowser
import matplotlib.pyplot as plot
from urllib.request import urlopen

with open('t1.txt','r')as f:
    x=f.read().split('\n')

img_names=[]

for line in x:
    for word in line.split(' '):
        if(len(word)>10):
            for j in word.split('\t'):
                img_names.append(j)

t='http://ec2-18-191-238-20.us-east-2.compute.amazonaws.com/PKxcCwfz/files/data/nifti-png3ch/t1/'

for i in img_names[5030:]:
    img_url = t+i
    r=requests.get(img_url)
    #image = urlopen(img).read()
    with open(i,'ab')as f:
        f.write(r.content)

你可能感兴趣的:(爬t1)