0004風吹けば名無し
2023/09/22(金) 22:01:25.76ID:nbE8GNPO0import json
import os
import requests
import time
from urllib import request as req
from IPython.display import Image, display, HTML
subscription_key = "_APIKEY_"
endpoint = "https://api.bing.microsoft.com/v7.0/images/search"
#検索ワード
query = "ero 2次 レイプ 赤ちゃんできちゃう 中出し"
# タイルの幅と高さを設定
tile_width = 200
# 画像を横に並べて表示するHTMLコードを生成
html_code = ""
for i in range(0, 10):
mkt = 'ja-JP'
params = { 'q': query, 'mkt': mkt, 'safeSearch': 'off', 'count':'150', 'offset': 150 * i}
headers = { 'Ocp-Apim-Subscription-Key': subscription_key }
try:
response = requests.get(endpoint, headers=headers, params=params)
data = json.loads(response.text)["value"]
for item in data:
try:
imgUrl = item['contentUrl']
image_code = f'<img src="{imgUrl}" width="{tile_width}" style="margin: 5px;">'
html_code += image_code
except Exception as ex_load:
print(ex_load)
except Exception as ex:
raise ex
HTML(html_code)