Python 自动下载xml中指定地址图片

'''
Python 自动下载xml中指定地址图片 by 郑瑞国
'''
import xml.dom.minidom
import requests

dom = xml.dom.minidom.parse('poto.xml')
rootdata = dom.documentElement
for i in range(0,1122):
    name = 'pic_'+str(i)
    itemlist = rootdata.getElementsByTagName(name)
    #print(itemlist[0].firstChild.data)
    IMAGE_URL = itemlist[0].firstChild.data
    print(IMAGE_URL)
    r = requests.get(IMAGE_URL)
    with open(r'd:/zrg/image/'+name+'.jpg','wb') as f:
        f.write(r.content)

 

你可能感兴趣的:(Python 自动下载xml中指定地址图片)