Demo
# Demo
# 示例
import asyncio
from loguru import logger
from PicImageSearch import Network, SauceNAO
from PicImageSearch.model import SauceNAOResponse
# 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"
api_key = "a4ab3f81009b003528f7e31aed187fa32a063f58"
bypass = True # 是否绕过 DNS 污染
@logger.catch()
async def test_async() -> None:
async with Network(proxies=proxies, bypass=bypass) as client:
saucenao = SauceNAO(client=client, api_key=api_key, hide=3)
# resp = await saucenao.search(url=url)
resp = await saucenao.search(file=file)
show_result(resp)
def show_result(resp: SauceNAOResponse) -> None:
logger.info(resp.status_code) # HTTP 状态码
logger.info(resp.origin) # 原始数据
logger.info(resp.url)
logger.info(resp.raw[0].origin)
logger.info(resp.long_remaining)
logger.info(resp.short_remaining)
logger.info(resp.raw[0].thumbnail)
logger.info(resp.raw[0].similarity)
logger.info(resp.raw[0].hidden)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].author)
logger.info(resp.raw[0].author_url)
logger.info(resp.raw[0].source)
logger.info(resp.raw[0].url)
logger.info(resp.raw[0].ext_urls)
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 SauceNAOResponse
from PicImageSearch.sync import SauceNAO as SauceNAOSync
# 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"
api_key = "a4ab3f81009b003528f7e31aed187fa32a063f58"
bypass = True # 是否绕过 DNS 污染
@logger.catch()
def test_sync() -> None:
saucenao = SauceNAOSync(proxies=proxies, bypass=bypass, api_key=api_key, hide=3)
resp = saucenao.search(url=url)
# resp = saucenao.search(file=file)
show_result(resp) # type: ignore
def show_result(resp: SauceNAOResponse) -> None:
logger.info(resp.status_code) # HTTP 状态码
logger.info(resp.origin) # 原始数据
logger.info(resp.url)
logger.info(resp.raw[0].origin)
logger.info(resp.long_remaining)
logger.info(resp.short_remaining)
logger.info(resp.raw[0].thumbnail)
logger.info(resp.raw[0].similarity)
logger.info(resp.raw[0].hidden)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].author)
logger.info(resp.raw[0].author_url)
logger.info(resp.raw[0].source)
logger.info(resp.raw[0].url)
logger.info(resp.raw[0].ext_urls)
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_saucenao.py
bgColor: '#DFEEE7'
textColor: '#2A3344'
程序输出
2022-10-06 01:14:01.327 | INFO | __main__:show_result:35 - 200
2022-10-06 01:14:01.328 | INFO | __main__:show_result:36 - {'header': {'user_id': '69131', 'account_type': '1', 'short_limit': '4', 'long_limit': '100', 'long_remaining': 96, 'short_remaining': 3, 'status': 0, 'results_requested': 5, 'index': {'0': {'status': 0, 'parent_id': 0, 'id': 0, 'results': 5}, '2': {'status': 0, 'parent_id': 2, 'id': 2, 'results': 5}, '5': {'status': 0, 'parent_id': 5, 'id': 5, 'results': 5}, '51': {'status': 0, 'parent_id': 5, 'id': 51, 'results': 5}, '52': {'status': 0, 'parent_id': 5, 'id': 52, 'results': 5}, '53': {'status': 0, 'parent_id': 5, 'id': 53, 'results': 5}, '6': {'status': 0, 'parent_id': 6, 'id': 6, 'results': 5}, '8': {'status': 0, 'parent_id': 8, 'id': 8, 'results': 5}, '9': {'status': 0, 'parent_id': 9, 'id': 9, 'results': 10}, '10': {'status': 0, 'parent_id': 10, 'id': 10, 'results': 5}, '11': {'status': 0, 'parent_id': 11, 'id': 11, 'results': 5}, '12': {'status': 0, 'parent_id': 9, 'id': 12, 'results': 10}, '16': {'status': 0, 'parent_id': 16, 'id': 16, 'results': 5}, '18': {'status': 0, 'parent_id': 18, 'id': 18, 'results': 5}, '19': {'status': 0, 'parent_id': 19, 'id': 19, 'results': 5}, '20': {'status': 0, 'parent_id': 20, 'id': 20, 'results': 5}, '21': {'status': 0, 'parent_id': 21, 'id': 21, 'results': 5}, '211': {'status': 0, 'parent_id': 21, 'id': 211, 'results': 5}, '22': {'status': 0, 'parent_id': 22, 'id': 22, 'results': 5}, '23': {'status': 0, 'parent_id': 23, 'id': 23, 'results': 5}, '24': {'status': 0, 'parent_id': 24, 'id': 24, 'results': 5}, '25': {'status': 0, 'parent_id': 9, 'id': 25, 'results': 10}, '26': {'status': 0, 'parent_id': 9, 'id': 26, 'results': 10}, '27': {'status': 0, 'parent_id': 9, 'id': 27, 'results': 10}, '28': {'status': 0, 'parent_id': 9, 'id': 28, 'results': 10}, '29': {'status': 0, 'parent_id': 9, 'id': 29, 'results': 10}, '30': {'status': 0, 'parent_id': 9, 'id': 30, 'results': 10}, '31': {'status': 0, 'parent_id': 31, 'id': 31, 'results': 5}, '32': {'status': 0, 'parent_id': 32, 'id': 32, 'results': 5}, '33': {'status': 0, 'parent_id': 33, 'id': 33, 'results': 5}, '34': {'status': 0, 'parent_id': 34, 'id': 34, 'results': 5}, '341': {'status': 0, 'parent_id': 341, 'id': 341, 'results': 5}, '35': {'status': 0, 'parent_id': 35, 'id': 35, 'results': 5}, '36': {'status': 0, 'parent_id': 36, 'id': 36, 'results': 5}, '37': {'status': 0, 'parent_id': 37, 'id': 37, 'results': 5}, '371': {'status': 0, 'parent_id': 371, 'id': 371, 'results': 5}, '38': {'status': 0, 'parent_id': 38, 'id': 38, 'results': 5}, '39': {'status': 0, 'parent_id': 39, 'id': 39, 'results': 5}, '40': {'status': 0, 'parent_id': 40, 'id': 40, 'results': 5}, '41': {'status': 0, 'parent_id': 41, 'id': 41, 'results': 5}, '42': {'status': 0, 'parent_id': 42, 'id': 42, 'results': 5}, '43': {'status': 0, 'parent_id': 43, 'id': 43, 'results': 5}, '44': {'status': 0, 'parent_id': 44, 'id': 44, 'results': 5}}, 'search_depth': '128', 'minimum_similarity': 29.99, 'query_image_display': '/userdata/InmMBy3Tl.jpg.png', 'query_image': 'InmMBy3Tl.jpg', 'results_returned': 5}, 'results': [{'header': {'similarity': '93.54', 'thumbnail': 'https://img1.saucenao.com/res/pixiv/9416/94165837_p0_master1200.jpg?auth=yOj6FS1fVYzGTIsEB1eKDQ&exp=1665514800', 'index_id': 5, 'index_name': 'Index #5: Pixiv Images - 94165837_p0_master1200.jpg', 'dupes': 0, 'hidden': 0}, 'data': {'ext_urls': ['https://www.pixiv.net/member_illust.php?mode=medium&illust_id=94165837'], 'title': 'いたずら', 'pixiv_id': 94165837, 'member_name': 'SyHan__', 'member_id': 12505972}}, {'header': {'similarity': '93.36', 'thumbnail': 'https://img3.saucenao.com/booru/6/e/6e0d18b51c232dc81b29f0c092c246e5_2.jpg?auth=9RFKBFbNQ4kJlSDJE9RNgA&exp=1665514800', 'index_id': 9, 'index_name': 'Index #9: Danbooru - 6e0d18b51c232dc81b29f0c092c246e5_0.jpg', 'dupes': 1, 'hidden': 0}, 'data': {'ext_urls': ['https://danbooru.donmai.us/post/show/4885675', 'https://gelbooru.com/index.php?page=post&s=view&id=6609225'], 'danbooru_id': 4885675, 'gelbooru_id': 6609225, 'creator': 'syhan', 'material': 'idolmaster, idolmaster shiny colors', 'characters': 'kazano hiori, producer (idolmaster)', 'source': 'https://twitter.com/SyHan__/status/1455439388393963521'}}, {'header': {'similarity': '93.14', 'thumbnail': 'https://img3.saucenao.com/booru/b/6/b6e3ffd8498ec187d019a94e1253d721_0.jpg?auth=Q_VS31BAgd4ykX6YHISHKw&exp=1665514800', 'index_id': 9, 'index_name': 'Index #9: Danbooru - b6e3ffd8498ec187d019a94e1253d721_0.jpg', 'dupes': 1, 'hidden': 0}, 'data': {'ext_urls': ['https://danbooru.donmai.us/post/show/4916870', 'https://gelbooru.com/index.php?page=post&s=view&id=6652192'], 'danbooru_id': 4916870, 'gelbooru_id': 6652192, 'creator': 'syhan', 'material': 'idolmaster, idolmaster shiny colors', 'characters': 'kazano hiori, producer (idolmaster)', 'source': 'https://i.pximg.net/img-original/img/2021/11/16/04/09/06/94165837'}}, {'header': {'similarity': '90.88', 'thumbnail': 'https://img3.saucenao.com/ehentai/42/0a/420a60c7b2ee90cac455f7b3576410d6074d1151.jpg?auth=jZ3mFI9F80NFeuHYyzoJQA&exp=1665514800', 'index_id': 38, 'index_name': 'Index #38: H-Misc (E-Hentai) - 420a60c7b2ee90cac455f7b3576410d6074d1151.jpg', 'dupes': 0, 'hidden': 0}, 'data': {'source': 'SyHan__', 'creator': ['Unknown'], 'eng_name': '[PIXIV] SyHan__ (12505972)', 'jp_name': ''}}, {'header': {'similarity': '47.41', 'thumbnail': 'https://img1.saucenao.com/res/pixiv/4942/manga/49426415_p17.jpg?auth=v7pGTp66Da8scGB4kcUDBA&exp=1665514800', 'index_id': 5, 'index_name': 'Index #5: Pixiv Images - 49426415_p17.jpg', 'dupes': 0, 'hidden': 0}, 'data': {'ext_urls': ['https://www.pixiv.net/member_illust.php?mode=medium&illust_id=49426415'], 'title': 'ゼスティリアやってきました', 'pixiv_id': 49426415, 'member_name': '榎本えのき', 'member_id': 10874969}}], 'status_code': 200}
2022-10-06 01:14:01.340 | INFO | __main__:show_result:37 - https://saucenao.com/search.php?url=https://saucenao.com/userdata/InmMBy3Tl.jpg.png
2022-10-06 01:14:01.341 | INFO | __main__:show_result:38 - {'header': {'similarity': '93.54', 'thumbnail': 'https://img1.saucenao.com/res/pixiv/9416/94165837_p0_master1200.jpg?auth=yOj6FS1fVYzGTIsEB1eKDQ&exp=1665514800', 'index_id': 5, 'index_name': 'Index #5: Pixiv Images - 94165837_p0_master1200.jpg', 'dupes': 0, 'hidden': 0}, 'data': {'ext_urls': ['https://www.pixiv.net/member_illust.php?mode=medium&illust_id=94165837'], 'title': 'いたずら', 'pixiv_id': 94165837, 'member_name': 'SyHan__', 'member_id': 12505972}}
2022-10-06 01:14:01.341 | INFO | __main__:show_result:39 - 96
2022-10-06 01:14:01.342 | INFO | __main__:show_result:40 - 3
2022-10-06 01:14:01.342 | INFO | __main__:show_result:41 - https://img1.saucenao.com/res/pixiv/9416/94165837_p0_master1200.jpg?auth=yOj6FS1fVYzGTIsEB1eKDQ&exp=1665514800
2022-10-06 01:14:01.342 | INFO | __main__:show_result:42 - 93.54
2022-10-06 01:14:01.343 | INFO | __main__:show_result:43 - 0
2022-10-06 01:14:01.343 | INFO | __main__:show_result:44 - いたずら
2022-10-06 01:14:01.343 | INFO | __main__:show_result:45 - SyHan__
2022-10-06 01:14:01.343 | INFO | __main__:show_result:46 - https://www.pixiv.net/artworks/94165837
2022-10-06 01:14:01.344 | INFO | __main__:show_result:47 - ['https://www.pixiv.net/member_illust.php?mode=medium&illust_id=94165837']
Edit this page on GitHub (opens new window)
上次更新: 2024/07/06, 00:28:18