jinyu121
2019-03-07 20:48:40 +08:00
```python
import xmltodict
import requests
import os
from tqdm import tqdm
data = open("网易博客图片列表.xml", "r").read()
data = xmltodict.parse(data)['root']['photo']
for url in tqdm(data):
tqdm.write(url)
try:
url = url.replace("?height=96&width=96", "")
filename = os.path.join("images", os.path.split(url)[-1])
r = requests.get(url, stream=True, timeout=60)
r.raise_for_status()
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
except:
tqdm.write("==> Error {}".format(url))
```
我忘了那个图片列表是从哪儿来的了……反正是宣布停运之后有地方能导出的