Code python - Tổng hợp API ảnh theo chủ đề

Code python - Tổng hợp API ảnh theo chủ đề

+ 1.  Chủ đề  ảnh Anime:
+ 1.  Chủ đề  ảnh Anime:
Hình ảnh anime

+ CODE:

import requests

thu_muc = "./"
headers = {
    'Accept-Version': 'v5'
}
params = {
    'included_tags': ['maid'],
    'height': '>=2000',
}
response = requests.get("https://api.waifu.im/search", headers=headers, params=params)
if response.status_code == 200:
    link_anh = requests.get(response.json()["images"][0]["url"])
    with open(thu_muc+"hinhanh.png", "wb") as luu:
        luu.write(link_anh.content)
    print("Hoàn thành tải ảnh")    
   
else:
    print("lỗi không tải được ảnh", response.status_code)

+ 2.  Chủ đề  ảnh Cáo:

+ 2.  Chủ đề  ảnh Cáo:
Hình ảnh cáo

+ CODE:

import requests

thu_muc = "./"
response = requests.get("https://randomfox.ca/floof/")
if response.status_code == 200:  
    link_anh = requests.get(response.json()["image"])
    with open(thu_muc+"hinhanh.png", "wb") as luu:
        luu.write(link_anh.content)
    print("Hoàn thành tải ảnh")    
   
else:
    print("lỗi không tải được ảnh", response.status_code)

Mới hơn Cũ hơn

Biểu mẫu liên hệ