Demo
import asyncio
from loguru import logger
from PicImageSearch import EHentai, Network
from PicImageSearch.model import EHentaiResponse
proxies = "http://127.0.0.1:1081"
# proxies = None
url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test06.jpg"
file = "images/test06.jpg"
cookies = None # 注意:如果要使用 EXHentai 搜索,需要提供 cookies
ex = False # 是否使用 EXHentai 搜索,推荐用 bool(cookies) ,即配置了 cookies 就使用 EXHentai 搜索
timeout = 60 # 尽可能避免超时返回空的 document
@logger.catch()
async def test_async() -> None:
async with Network(proxies=proxies, cookies=cookies, timeout=timeout) as client:
ehentai = EHentai(client=client)
# resp = await ehentai.search(url=url, ex=ex)
resp = await ehentai.search(file=file, ex=ex)
show_result(resp)
def show_result(resp: EHentaiResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.url) # 搜索结果链接
# logger.info(resp.raw[0].origin)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].url)
logger.info(resp.raw[0].thumbnail)
logger.info(resp.raw[0].type)
logger.info(resp.raw[0].date)
logger.info(resp.raw[0].tags) # 推荐使用 Compact / Extended 页面布局,否则拿不到 tags
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 EHentaiResponse
from PicImageSearch.sync import EHentai as EHentaiSync
proxies = "http://127.0.0.1:1081"
# proxies = None
url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test06.jpg"
file = "images/test06.jpg"
cookies = None # 注意:如果要使用 EXHentai 搜索,需要提供 cookies
ex = False # 是否使用 EXHentai 搜索,推荐用 bool(cookies) ,即配置了 cookies 就使用 EXHentai 搜索
timeout = 60 # 尽可能避免超时返回空的 document
@logger.catch()
def test_sync() -> None:
ehentai = EHentaiSync(proxies=proxies, cookies=cookies, timeout=timeout)
resp = ehentai.search(url=url, ex=ex)
# resp = ehentai.search(file=file, ex=ex)
show_result(resp) # type: ignore
def show_result(resp: EHentaiResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.url) # 搜索结果链接
# logger.info(resp.raw[0].origin)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].url)
logger.info(resp.raw[0].thumbnail)
logger.info(resp.raw[0].type)
logger.info(resp.raw[0].date)
logger.info(resp.raw[0].tags) # 推荐使用 Compact / Extended 页面布局,否则拿不到 tags
logger.info("-" * 50)
if __name__ == "__main__":
test_sync()
// Make sure to add code blocks to your code group
⚠注意
E-Hentai
与 ExHentai
不支持单色图片的搜索,例如 黑白漫画
只推荐用于搜索 CG、画集、彩本、图集等
- name: 前往查看
desc: 🚀 测试文件 Demo
link: https://github.com/kitUIN/PicImageSearch/blob/main/demo/cn/demo_ehentai.py
bgColor: '#DFEEE7'
textColor: '#2A3344'
注意
建议把 timeout 的值设置大些
程序输出
2022-10-06 01:12:20.991 | INFO | __main__:show_result:37 - https://e-hentai.org/?f_shash=2b678c36f666bf7037146fb377ffd9384505af8b;e6eb91d1bf73e0c367188fd7a0b0f7c9757addfc;bb9f35a23e1fe20949a7bc5eb605db9dc25e3758&fs_from=test06.jpg&fs_similar=on
2022-10-06 01:12:20.992 | INFO | __main__:show_result:39 - [MIGNON WORKS (mignon)] Heso Dashi Look [Chinese] [绅士仓库汉化]
2022-10-06 01:12:20.992 | INFO | __main__:show_result:40 - https://e-hentai.org/g/2088139/c686827a7e/
2022-10-06 01:12:20.992 | INFO | __main__:show_result:41 - https://ehgt.org/t/bb/9f/bb9f35a23e1fe20949a7bc5eb605db9dc25e3758-9205912-2566-3600-png_250.jpg
2022-10-06 01:12:20.992 | INFO | __main__:show_result:42 - Non-H
2022-10-06 01:12:20.992 | INFO | __main__:show_result:43 - 2021-12-18 14:49
2022-10-06 01:12:20.993 | INFO | __main__:show_result:44 - ['chinese', 'translated', 'f:fishnets', 'f:pantyhose', 'f:school gym uniform', 'f:schoolgirl uniform', 'f:swimsuit', 'mignon works', 'mignon', 'artbook', 'full color']
在 GitHub 上编辑此页 (opens new window)
上次更新: 2024/07/27, 01:25:05