Demo
# Demo
# 示例
import asyncio
from loguru import logger
from PicImageSearch import Iqdb, Network
from PicImageSearch.model import IqdbResponse
# proxies = "http://127.0.0.1:1081"
proxies = None
url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test01.jpg"
file = "images/test01.jpg"
bypass = False # 绕过 DNS 污染
@logger.catch()
async def test_async() -> None:
async with Network(proxies=proxies, bypass=bypass) as client:
iqdb = Iqdb(client=client)
# resp = await iqdb.search(url=url)
resp = await iqdb.search(file=file)
show_result(resp)
def show_result(resp: IqdbResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.url)
# logger.info(resp.raw[0].origin)
logger.info(f"说明: {resp.raw[0].content}")
logger.info(f"来源地址: {resp.raw[0].url}")
logger.info(f"缩略图: {resp.raw[0].thumbnail}")
logger.info(f"相似度: {resp.raw[0].similarity}")
logger.info(f"图片大小: {resp.raw[0].size}")
logger.info(f"图片来源: {resp.raw[0].source}")
logger.info(f"其他图片来源: {resp.raw[0].other_source}")
logger.info(f"SauceNAO搜图链接: {resp.saucenao_url}")
logger.info(f"Ascii2d搜图链接: {resp.ascii2d_url}")
logger.info(f"TinEye搜图链接: {resp.tineye_url}")
logger.info(f"Google搜图链接: {resp.google_url}")
logger.info(f"相似度低的结果有多少: {len(resp.more)}")
logger.info("-" * 50)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(test_async())
from loguru import logger
from PicImageSearch.model import IqdbResponse
from PicImageSearch.sync import Iqdb as IqdbSync
# proxies = "http://127.0.0.1:1081"
proxies = None
url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test01.jpg"
file = "images/test01.jpg"
bypass = False # 绕过 DNS 污染
@logger.catch()
def test_sync() -> None:
iqdb = IqdbSync(proxies=proxies, bypass=bypass)
resp = iqdb.search(url=url)
# resp = iqdb.search(file=file)
show_result(resp) # type: ignore
def show_result(resp: IqdbResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.url)
# logger.info(resp.raw[0].origin)
logger.info(f"说明: {resp.raw[0].content}")
logger.info(f"来源地址: {resp.raw[0].url}")
logger.info(f"缩略图: {resp.raw[0].thumbnail}")
logger.info(f"相似度: {resp.raw[0].similarity}")
logger.info(f"图片大小: {resp.raw[0].size}")
logger.info(f"图片来源: {resp.raw[0].source}")
logger.info(f"其他图片来源: {resp.raw[0].other_source}")
logger.info(f"SauceNAO搜图链接: {resp.saucenao_url}")
logger.info(f"Ascii2d搜图链接: {resp.ascii2d_url}")
logger.info(f"TinEye搜图链接: {resp.tineye_url}")
logger.info(f"Google搜图链接: {resp.google_url}")
logger.info(f"相似度低的结果有多少: {len(resp.more)}")
logger.info("-" * 50)
if __name__ == "__main__":
test_sync()
// Make sure to add code blocks to your code group
- name: 前往查看
desc: 🚀 异步测试文件 Demo
link: https://github.com/kitUIN/PicImageSearch/blob/main/demo/cn/demo_iqdb_3d.py
bgColor: '#DFEEE7'
textColor: '#2A3344'
程序输出
2022-10-06 01:13:26.024 | INFO | __main__:show_result:35 - https://iqdb.org/?url=https://iqdb.org/thu/thu_cbf09440.jpg
2022-10-06 01:13:26.025 | INFO | __main__:show_result:37 - 说明: Best match
2022-10-06 01:13:26.025 | INFO | __main__:show_result:38 - 来源地址: https://danbooru.donmai.us/posts/4885675
2022-10-06 01:13:26.025 | INFO | __main__:show_result:39 - 缩略图: https://iqdb.org/danbooru/6/e/0/6e0d18b51c232dc81b29f0c092c246e5.jpg
2022-10-06 01:13:26.025 | INFO | __main__:show_result:40 - 相似度: 91.0
2022-10-06 01:13:26.025 | INFO | __main__:show_result:41 - 图片大小: 2504×3180 [Safe]
2022-10-06 01:13:26.025 | INFO | __main__:show_result:42 - 图片来源: Danbooru
2022-10-06 01:13:26.025 | INFO | __main__:show_result:43 - 其他图片来源: []
2022-10-06 01:13:26.025 | INFO | __main__:show_result:44 - SauceNAO 搜图链接: https://saucenao.com/search.php?db=999&dbmaski=32768&url=https://iqdb.org/thu/thu_cbf09440.jpg
2022-10-06 01:13:26.025 | INFO | __main__:show_result:45 - Ascii2d 搜图链接: https://ascii2d.net/search/url/https://iqdb.org/thu/thu_cbf09440.jpg
2022-10-06 01:13:26.026 | INFO | __main__:show_result:46 - TinEye 搜图链接: https://tineye.com/search?url=https://iqdb.org/thu/thu_cbf09440.jpg
2022-10-06 01:13:26.026 | INFO | __main__:show_result:47 - Google 搜图链接: https://www.google.com/searchbyimage?image_url=https://iqdb.org/thu/thu_cbf09440.jpg&safe=off
2022-10-06 01:13:26.026 | INFO | __main__:show_result:48 - 相似度低的结果有多少: 12
Edit this page on GitHub (opens new window)
上次更新: 2024/06/30, 23:31:36