From 5cee08434053bf49c042106bca95b2ce529f598b Mon Sep 17 00:00:00 2001 From: QIN2DIM <62018067+QIN2DIM@users.noreply.github.com> Date: Sat, 18 May 2024 23:31:11 +0800 Subject: [PATCH] fix(main): UnicodeDecodeError File "T:\_GitHubProjects\Forks\crawl4ai\main.py", line 70, in read_index partials[filename[:-5]] = file.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 149: illegal multibyte sequence --- .gitignore | 3 ++- main.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9aac8182..846ac59a 100644 --- a/.gitignore +++ b/.gitignore @@ -173,4 +173,5 @@ Crawl4AI.egg-info/ requirements0.txt a.txt -*.sh \ No newline at end of file +*.sh +.idea \ No newline at end of file diff --git a/main.py b/main.py index 20ee0acb..acd247c0 100644 --- a/main.py +++ b/main.py @@ -66,7 +66,7 @@ async def read_index(request: Request): for filename in os.listdir(partials_dir): if filename.endswith(".html"): - with open(os.path.join(partials_dir, filename), "r") as file: + with open(os.path.join(partials_dir, filename), "r", encoding="utf8") as file: partials[filename[:-5]] = file.read() return templates.TemplateResponse("index.html", {"request": request, **partials})