Closed OPlincn closed 3 months ago
如果启用了WITH_TAG, 那么collect tag的过程中就会报错: encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00 encoding error : input conversion failed due to input error, bytes 0x44 0x00 0x00 0x00 I/O error : encoder error
WITH_TAG
encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00 encoding error : input conversion failed due to input error, bytes 0x44 0x00 0x00 0x00 I/O error : encoder error
找了半天,发现是pixiv_crawler/collector/selectors.py中的 python PyQuery(response.text).find( "#meta-preload-data").attr("content"))
pixiv_crawler/collector/selectors.py
python PyQuery(response.text).find( "#meta-preload-data").attr("content"))
这段代码出现了问题, PyQuery不知道为什么解析一些tag的时候会出现 encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00这样的编码错误,
PyQuery
encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00
而如果将PyQuery换成BeautifulSoup来解析html文件,这个问题就解决了
BeautifulSoup
并且我发现PyQuery这个库,只有这个地方用到了,所以我将其从requirements.txt中删除了,并加入安装了bs4库. 我看issue里有多个人也出现了这个问题, 换个库来解析这样应该能够彻底解决这个问题(?) 更换后的效果如下:
requirements.txt
bs4
我的测试环境为: Python 3.10.14 MacOS 14.5 (Sonoma) M1 Silicon
感谢提交PR,我会这两天尽快看一下 👍
好的好的,麻烦了(^▽^)
如果启用了
WITH_TAG
, 那么collect tag的过程中就会报错:encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00 encoding error : input conversion failed due to input error, bytes 0x44 0x00 0x00 0x00 I/O error : encoder error
找了半天,发现是
pixiv_crawler/collector/selectors.py
中的python PyQuery(response.text).find( "#meta-preload-data").attr("content"))
这段代码出现了问题,
PyQuery
不知道为什么解析一些tag的时候会出现encoding error : input conversion failed due to input error, bytes 0x21 0x00 0x00 0x00
这样的编码错误,而如果将
PyQuery
换成BeautifulSoup
来解析html文件,这个问题就解决了并且我发现
PyQuery
这个库,只有这个地方用到了,所以我将其从requirements.txt
中删除了,并加入安装了bs4
库. 我看issue里有多个人也出现了这个问题, 换个库来解析这样应该能够彻底解决这个问题(?) 更换后的效果如下:我的测试环境为: Python 3.10.14 MacOS 14.5 (Sonoma) M1 Silicon