12345678910111213141516171819202122232425262728293031 |
- #!/usr/bin/env python3
- # -*- coding:utf-8 -*-
- import requests # http客户端
- import os # 创建文件夹
- import time
- from PIL import Image
- os.makedirs('./image/', exist_ok=True)
- IMAGE_URL = "https://app.yunnan.chinatax.gov.cn/app/base/captcha.do?time=" + (str(round(time.time() * 1000)))
- print(IMAGE_URL)
- head = {
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
- }
- def request_download(num):
- r = requests.get(IMAGE_URL, headers=head)
- with open('./image/%s.png' % str(num), 'wb') as f:
- f.write(r.content)
- try:
- for i in range(100):
- request_download((i+1))
- print('download to ./image/%s.png' % str((i+1)))
- #im = Image.open('./image/img.png')
- #im.show()
- except:
- print('download error!')
|