Li4n0 / hugo_encryptor

A tools for encrypting hugo posts
155 stars 28 forks source link

编码问题导致运行出错 #6

Closed jiang849725768 closed 3 years ago

jiang849725768 commented 4 years ago

运行python hugo-encryptor.py出现如下错误:

Traceback (most recent call last):
  File "hugo-encryptor.py", line 33, in <module>
    soup = BeautifulSoup(open(fullpath),'lxml')
  File "C:\anaconda3\lib\site-packages\bs4\__init__.py", line 244, in __init__
    markup = markup.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 2466: illegal multibyte sequence
oyiadin commented 4 years ago

Hi,应该解决了,git pull 后重新运行试试 ;-)

jiang849725768 commented 4 years ago

抱歉,出现了新的问题,我的系统是win10,请问是否是问题的原因?

Traceback (most recent call last):
  File "hugo-encryptor.py", line 56, in <module>
    soup = BeautifulSoup(open(xmlpath),'xml')
FileNotFoundError: [Errno 2] No such file or directory: './public/index.xml'

以下是public文件夹的文件截图 public

oyiadin commented 4 years ago

我们有个小功能忘记考虑这个边缘情况了,git pull 后应该就没问题了~十分抱歉~

jiang849725768 commented 4 years ago
Traceback (most recent call last):
  File "hugo-encryptor.py", line 86, in <module>
    f.write(str(soup))
UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 3181: illegal multibyte sequence

十分感谢你们的帮助,屡次麻烦实在是不好意思

oyiadin commented 4 years ago

呃,还是编码问题,稍等哈…我这边是 mac,一直能跑通就没大注意=。=

Edited: 手头没有 win,等我找台机器测通了再上(

oyiadin commented 4 years ago

Hi,手头没有 windows 机器,我怕改完你那边发现又有问题,等我找到机器自己试一下先。

这个报错出现在对 feed 的处理上,你现在可以直接忽略这个报错。因为,如果你在需要加密的文本前有加上一行 <!--more--> 的话,Hugo 就不会将你的加密部分内容放入 feed 中,feed 不经过 hugo-encryptor 的处理也不会泄露信息。

OrangeSodahub commented 3 years ago
Traceback (most recent call last):
  File "hugo-encryptor.py", line 86, in <module>
    f.write(str(soup))
UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 3181: illegal multibyte sequence

十分感谢你们的帮助,屡次麻烦实在是不好意思

请问你现在解决了吗

jiang849725768 commented 3 years ago
Traceback (most recent call last):
  File "hugo-encryptor.py", line 86, in <module>
    f.write(str(soup))
UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 3181: illegal multibyte sequence

十分感谢你们的帮助,屡次麻烦实在是不好意思

请问你现在解决了吗

抱歉很久没用了,不太记得了,如果还有同样的问题新开一个issue问问吧