NewFuture / DDNS

:triangular_flag_on_post: 自动更新域名解析到本机IP(支持dnspod,阿里DNS,CloudFlare,华为云,DNSCOM...)
https://ddns.newfuture.cc/
MIT License
4.29k stars 655 forks source link

[debug] SOHU 获取IP的API编码问题 #150

Closed hexistore closed 4 years ago

hexistore commented 4 years ago

当使用public方式获取ipv4地址时,程序出错,无法更新 ERROR:root:'utf-8' codec can't decode byte 0xb9 in position 72: invalid start byte

后更改了ip.py中_open的read编码为GBK,问题解决

debug output [调试输出]

2020-03-18 10:38:54,062 <run.main> 182@//10.6.0.1/Multimedia/DDNS/run.py
[WARNING] Cache file is out of dated.
2020-03-18 10:38:54,077 <ip._open> 51@\\10.6.0.1\Multimedia\DDNS\util\ip.py 
[DEBUG] open: https://pv.sohu.com/cityjson
2020-03-18 10:38:54,188 <ip._open> 58@\\10.6.0.1\Multimedia\DDNS\util\ip.py 
[ERROR] 'utf-8' codec can't decode byte 0xb9 in position 72: invalid start byte
NewFuture commented 4 years ago

https://github.com/NewFuture/DDNS/issues/130#issuecomment-592963674 是否是这个问题

可以加个feature ,根据响应头指定的编码方式进行解码

hexistore commented 4 years ago

不是,我用的版本使用的SOHU的地址,访问正常,内容有中文,用UTF8解码就报错了

NewFuture commented 4 years ago

https://pv.sohu.com/cityjson?ie=utf-8 可以用加上这个参数指定编码格式