https://api.vvhan.com/dongman.html
https://api.vvhan.com/api/acgimg
get
字段 |
类型 |
描述 |
return |
str |
响应数据格式,可选json |
| import json, requests |
| url = 'https://api.vvhan.com/api/acgimg' |
| params = {'type': 'json'} |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| { |
| "success": true, |
| "imgurl": "https://cdn.jsdelivr.net/gh/uxiaohan/GitImgTypecho/Acg/api.vvhan.com[337].jpg", |
| "info": { |
| "width": 1920, |
| "height": 1080, |
| "type": "img" |
| } |
| } |
调用多次发现,该接口返回的图片尺寸大多是1920x1800
,且图片url
地址中只有最后[ ]
里面的数值在变化,截止目前该变化范围是0-696
,也就是该接口是从697
张二次元图片中随机返回一张。如果你想下载该接口所有的697
张图片,可以使用下方代码:
| '''依赖模块 |
| pip install requests |
| ''' |
| import concurrent.futures as cf |
| import os, time, requests |
| |
| |
| def down(fname, url): |
| res = requests.get(url) |
| with open(fname, 'wb') as f: |
| f.write(res.content) |
| |
| |
| def show(num, _sum, runTime): |
| barLen = 20 |
| perFin = num/_sum |
| numFin = round(barLen*perFin) |
| numNon = barLen-numFin |
| leftTime = (1-perFin)*(runTime/perFin) |
| print( |
| f"{num:0>{len(str(_sum))}}/{_sum}", |
| f"|{'█'*numFin}{' '*numNon}|", |
| f"PROCESS: {perFin*100:.0f}%", |
| f"RUN: {runTime:.0f}S", |
| f"ETA: {leftTime:.0f}S", |
| end='\r' |
| ) |
| if num == _sum: |
| print() |
| |
| |
| def main(): |
| floder = './img/' |
| os.makedirs(floder, exist_ok=True) |
| fmt = 'https://cdn.jsdelivr.net/gh/uxiaohan/GitImgTypecho/Acg/api.vvhan.com[{}].jpg' |
| total = 697 |
| with cf.ThreadPoolExecutor() as tp: |
| t1 = time.time() |
| futures = [] |
| for i in range(total): |
| url = fmt.format(i) |
| fname = floder+os.path.basename(url) |
| future = tp.submit(down, fname, url) |
| futures.append(future) |
| count = 0 |
| for future in cf.as_completed(futures): |
| count += 1 |
| t2 = time.time() |
| show(count, total, t2-t1) |
| os.system('pause') |
| |
| |
| main() |

http://www.dmoe.cc/
http://www.dmoe.cc/random.php
get
字段 |
类型 |
描述 |
return |
str |
响应数据格式,可选json |
| import json, requests |
| url = 'http://www.dmoe.cc/random.php' |
| params = {'return': 'json'} |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| { |
| "code": "200", |
| "imgurl": "https://tva1.sinaimg.cn/large/0072Vf1pgy1foxkil4o6qj31hc0u0nbz.jpg", |
| "width": "1920", |
| "height": "1080" |
| } |
http://img.xjh.me/
https://img.xjh.me/random_img.php
http://img.xjh.me/random_img.php
get
字段 |
类型 |
描述 |
return |
str |
响应数据格式,可选json或302 |
type |
str |
返回图片类型,可选bg即背景图 |
ctype |
str |
背景图类型,可选acg或nature |
| import json, requests |
| url = 'https://img.xjh.me/random_img.php' |
| params = { |
| 'return': 'json', |
| 'type': 'bg', |
| 'cytpe': 'acg' |
| } |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| { |
| "error": 0, |
| "result": 200, |
| "img": "//img.xjh.me/desktop/bg/acg/53829526_p0.jpg" |
| } |
https://www.nck.cc/index.php/archives/3/
https://www.rrll.cc/tuceng/ecy.php
get
字段 |
类型 |
描述 |
return |
str |
响应数据格式,可选json |
| url = 'https://www.rrll.cc/tuceng/ecy.php' |
| params = { |
| 'return': 'json' |
| } |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| { |
| "code": "200", |
| "acgurl": "https://tva4.sinaimg.cn/large/0072Vf1pgy1foxkgc5msdj31hc0u01cv.jpg", |
| "width": "1920", |
| "height": "1080", |
| "size": "jpg" |
| } |
https://api.ghser.com/acg.html
https://api.ghser.com/random/api.php
get/post
空
| import json, requests |
| url = 'https://api.ghser.com/random/api.php' |
| res = requests.get(url) |
| print(res.url) |
返回302
重定向后的图片url
| https://tva1.sinaimg.cn/large/006gkh44ly1fz1kddbampj31hc0u0tyb.jpg |
https://acg.yanwz.cn/
https://acg.yanwz.cn/wallpaper/api.php
get
空
| import json, requests |
| url = 'https://acg.yanwz.cn/wallpaper/api.php' |
| res = requests.get(url) |
| with open('test.jpg', 'wb') as f: |
| f.write(res.content) |
二进制流图片
https://www.eee.dog/tech/rand-pic-api.html
https://api.yimian.xyz/img
get/post
字段 |
类型 |
描述 |
type |
str |
图片类型,可选moe为二次元图 |
size |
str |
图片大小,可选1920×1080 |
| import json, requests |
| url = 'https://api.yimian.xyz/img' |
| params = { |
| 'type': 'moe', |
| 'size': '1920x1080' |
| } |
| res = requests.get(url, params=params) |
| print(res.url) |
返回302
重定向后的图片url
| https://yimian-image.obs.cn-east-2.myhuaweicloud.com/moe/img_865_2048x1152_96.5199966430664_null_normal.jpg?AWSAccessKeyId=6LJRZC0YN3MQXXFOWMIH&Expires=1608815304&Signature=C5BWWC/r1/o230t1VVLHHmH0kF4%3D |

| |
| import json, requests |
| url = 'https://api.vvhan.com/api/acgimg' |
| params = {'type': 'json'} |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| |
| |
| |
| import json, requests |
| url = 'http://www.dmoe.cc/random.php' |
| params = {'return': 'json'} |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| |
| |
| |
| import json, requests |
| url = 'https://img.xjh.me/random_img.php' |
| params = { |
| 'return': 'json', |
| 'type': 'bg', |
| 'cytpe': 'acg' |
| } |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| |
| |
| |
| import json, requests |
| url = 'https://www.rrll.cc/tuceng/ecy.php' |
| params = { |
| 'return': 'json' |
| } |
| res = requests.get(url, params=params).json() |
| print(json.dumps(res, indent=2)) |
| |
| |
| |
| import json, requests |
| url = 'https://api.ghser.com/random/api.php' |
| res = requests.get(url) |
| print(res.url) |
| |
| |
| |
| import json, requests |
| url = 'https://acg.yanwz.cn/wallpaper/api.php' |
| res = requests.get(url) |
| with open('test.jpg', 'wb') as f: |
| f.write(res.content) |
| |
| |
| import json, requests |
| url = 'https://api.yimian.xyz/img' |
| params = { |
| 'type': 'moe', |
| 'size': '1920x1080' |
| } |
| res = requests.get(url, params=params) |
| print(res.url) |
以樱花API
为例
| <img src="http://www.dmoe.cc/random.php"/> |
| <body style="background: url(http://www.dmoe.cc/random.php);"></body> |
其它API
只需要替换src
或url
属性值为以下值
| 1. 韩小韩API |
| https://api.vvhan.com/api/acgimg |
| 2. 樱花API |
| http://www.dmoe.cc/random.php |
| 3. 岁月小筑API |
| https://img.xjh.me/random_img.php?return=302 |
| 4. Lucky小站API |
| https://www.rrll.cc/tuceng/ecy.php |
| 5. 一叶三秋API |
| https://api.ghser.com/random/api.php |
| 6. 汐岑API |
| https://acg.yanwz.cn/wallpaper/api.php |
| 7. 呓喵酱API |
| https://api.yimian.xyz/img |