XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Fix unicode errors in web_search

9d6777e2
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +2 -2
Modified g4f/tools/web_search.py +2 -2
@@ -104,7 +104,7 @@ def scrape_text(html: str, max_words: int = None, add_source=True, count_images:
104 104 count_images -= 1
105 105 continue
106 106
107 for line in paragraph.text.splitlines():
107 for line in paragraph.get_text(" ").splitlines():
108 108 words = [word for word in line.split() if word]
109 109 count = len(words)
110 110 if not count:
@@ -136,7 +136,7 @@ async def fetch_and_scrape(session: ClientSession, url: str, max_words: int = No
136 136 return cache_file.read_text()
137 137 async with session.get(url) as response:
138 138 if response.status == 200:
139 html = await response.text()
139 html = await response.text(errors="replace")
140 140 text = "".join(scrape_text(html, max_words, add_source))
141 141 with open(cache_file, "w") as f:
142 142 f.write(text)