Go 安装 golang.org/x/text 出错

本文介绍了解决Go爬虫抓取GBK编码数据并转换为UTF-8的方法。遇到字符集转换问题时,可通过特定步骤手动安装golang.org/x/text库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    今天在写一个Go爬虫的时候,从指定url中抓到数据,然后中文全是乱码,抓取的数据字符集是GBK,然后要将字符集转化成UTF-8,要安装一个库,所以go get golang.org/x/text,之后报错:package golang.org/x/text: unrecognized import path "golang.org/x/text" (https fetch: Get https://golang.org/x/text?go-get=1: dial tcp 119.28.87.227:443: i/o timeout),然后百度在这篇博客http://blog.youkuaiyun.com/alexwoo0501/article/details/73409917里解决方法,原因是因为这个官方包在国外服务器上。

    解决方法有两种:翻墙或在github上下载

获取 golang.org/x/net 包,其实只需要以下步骤:

mkdir -p $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/text.git
  • 其它 golang.org/x 下的包获取都可以使用该方法

参考博客:http://blog.youkuaiyun.com/alexwoo0501/article/details/73409917

After restarting ComfyUI, please refresh the browser. translate\translate.go:25:2: github.com/abadojack/whatlanggo@v1.0.1: Get "https://proxy.golang.org/github.com/abadojack/whatlanggo/@v/v1.0.1.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. translate\translate.go:28:2: github.com/andybalholm/brotli@v1.1.0: Get "https://proxy.golang.org/github.com/andybalholm/brotli/@v/v1.1.0.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. translate\translate.go:26:2: github.com/imroc/req/v3@v3.48.0: Get "https://proxy.golang.org/github.com/imroc/req/v3/@v/v3.48.0.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. translate\translate.go:29:2: github.com/tidwall/gjson@v1.14.3: Get "https://proxy.golang.org/github.com/tidwall/gjson/@v/v1.14.3.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. service\service.go:23:2: github.com/gin-contrib/cors@v1.6.0: Get "https://proxy.golang.org/github.com/gin-contrib/cors/@v/v1.6.0.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. service\service.go:24:2: github.com/gin-gonic/gin@v1.9.1: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/v1.9.1.zip": dial tcp 142.251.33.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [ComfyUI-Manager] Failed to perform initial fetching 'custom-node-list.json': Traceback (most recent call last): File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 347, in _wait await waiter asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\ComfyUI\custom_nodes\comfyui-manager\glob\manager_server.py", line 1729, in get_cache json_obj = await manager_util.get_data(uri, True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\ComfyUI\custom_nodes\comfyui-manager\glob\manager_util.py", line 146, in get_data json_text = await resp.text() ^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\client_reqrep.py", line 1260, in text await self.read() File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\client_reqrep.py", line 1218, in read self._body = await self.content.read() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 418, in read block = await self.readany() ^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 440, in readany await self._wait("readany") File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 346, in _wait with self._timer: File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\helpers.py", line 685, in __exit__ raise asyncio.TimeoutError from exc_val TimeoutError [ComfyUI-Manager] Failed to perform initial fetching 'extension-node-map.json': Traceback (most recent call last): File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 347, in _wait await waiter asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\ComfyUI\custom_nodes\comfyui-manager\glob\manager_server.py", line 1729, in get_cache json_obj = await manager_util.get_data(uri, True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\ComfyUI\custom_nodes\comfyui-manager\glob\manager_util.py", line 146, in get_data json_text = await resp.text() ^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\client_reqrep.py", line 1260, in text await self.read() File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\client_reqrep.py", line 1218, in read self._body = await self.content.read() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 418, in read block = await self.readany() ^^^^^^^^^^^^^^^^^^^^ File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 440, in readany await self._wait("readany") File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\streams.py", line 346, in _wait with self._timer: File "C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\python\Lib\site-packages\aiohttp\helpers.py", line 685, in __exit__ raise asyncio.TimeoutError from exc_val TimeoutError FETCH ComfyRegistry Data: 5/85 FETCH ComfyRegistry Data: 10/85 FETCH ComfyRegistry Data: 15/85 FETCH ComfyRegistry Data: 20/85 FETCH ComfyRegistry Data: 25/85 FETCH ComfyRegistry Data: 30/85 FETCH ComfyRegistry Data: 35/85 FETCH ComfyRegistry Data: 40/85 FETCH ComfyRegistry Data: 45/85 FETCH ComfyRegistry Data: 50/85 FETCH ComfyRegistry Data: 55/85 FETCH ComfyRegistry Data: 60/85 FETCH ComfyRegistry Data: 65/85 FETCH ComfyRegistry Data: 70/85 FETCH ComfyRegistry Data: 75/85 FETCH ComfyRegistry Data: 80/85 FETCH ComfyRegistry Data: 85/85 FETCH ComfyRegistry Data [DONE] [ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json[ComfyUI-Manager] Due to a network error, switching to local mode. => custom-node-list.json => FETCH DATA from: C:\Documents\Ai\ComfyUI-aki\ComfyUI-aki-v1.6\ComfyUI\custom_nodes\comfyui-manager\custom-node-list.json [DONE] [ComfyUI-Manager] All startup tasks have been completed. [Crystools ERROR] For some reason, pynvml is not working in a laptop with only battery, try to connect and turn on the monitor [Crystools ERROR] Monitor of GPU is turning off (not on UI!) [BizyAir] Fail to get notification unread counts: Cannot connect to host api.bizyair.cn:443 ssl:default [getaddrinfo failed] 我在comfyUI中安装nunchaku有些问题 这个应该怎么修复呢
05-14
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值