master
jinql 2025-09-10 22:15:07 +08:00
parent 0adc1e717d
commit ce4135a809
2 changed files with 6 additions and 13 deletions

View File

@ -125,6 +125,8 @@ async def get_icon_async(entity: Favicon, _cached: bytes = None) -> Optional[byt
lambda: ('', "网站默认位置/favicon.ico"), lambda: ('', "网站默认位置/favicon.ico"),
# 4. 从其他api接口获取 # 4. 从其他api接口获取
lambda: (f'https://ico.kucat.cn/get.php?url={entity.get_base_url()}', "第三方API"), lambda: (f'https://ico.kucat.cn/get.php?url={entity.get_base_url()}', "第三方API"),
# 99. 最后的尝试cloudflare workers
# lambda: (f'https://favicon.cary.cc/?url={entity.get_base_url()}', "cloudflare"),
] ]
for strategy in strategies: for strategy in strategies:
@ -193,8 +195,6 @@ def _parse_html(content: Optional[bytes], entity: Favicon) -> Optional[str]:
try: try:
# 尝试将bytes转换为字符串 # 尝试将bytes转换为字符串
# str(content).encode('utf-8', 'replace').decode('utf-8', 'replace')
# content_str = content.decode('utf-8', 'replace')
content_str = str(content).encode('utf-8', 'replace').decode('utf-8', 'replace') content_str = str(content).encode('utf-8', 'replace').decode('utf-8', 'replace')
# 使用更高效的解析器 # 使用更高效的解析器

15
run.py
View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import asyncio
import uvicorn import uvicorn
@ -8,21 +10,12 @@ async def main():
"main:app", "main:app",
host="127.0.0.1", host="127.0.0.1",
port=8000, port=8000,
# reload=True, reload=False,
log_level="info", log_level="info",
) )
server = uvicorn.Server(config) server = uvicorn.Server(config)
await server.serve() await server.serve()
# asyncio.run(main())
if __name__ == "__main__": if __name__ == "__main__":
config = uvicorn.Config( asyncio.run(main())
"main:app",
host="127.0.0.1",
port=8000,
# reload=True,
log_level="info",
)
server = uvicorn.Server(config)
server.run()