我的移动网络对编码有何影响?
What's the effect of my mobile network on encoding?
我很聪明phone。在这个 smartphone 上,我有一个移动热点,本质上是一个便携式 WiFi 网络,可以将我的 phone 的互联网访问通过管道传输到我的笔记本电脑。
在我的笔记本电脑上,我有 Python 3 和 requests library。这里使用 Python 并请求获取 google.com
,以及我的 phone 的热点。 (结果与使用 "real wifi" 完全相同。)
>>> x = requests.get("http://google.com")
>>> x.apparent_encoding; x[:100]
'ISO-8859-2'
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content'
好!一切都在按计划进行。
也在我的笔记本电脑上,我有 Factor,它在标准库中有一个易于使用的 wgetter。 http-get
在 "normal" WiFi 网络上工作。
IN: scratchpad "http://google.com" http-get nip
--- Data stack:
"<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org..."
成功!
嗯,不。 http-get
在我的 phone 的热点上:
IN: scratchpad "http://google.com" http-get nip
--- Data stack:
"\x1f\b[=12=][=12=][=12=][=12=][=12=][=12=]\x03Å<ëzÛ¶ÿÏSÐH+K+\"u\x17eÚ&iâÓ¤Ik§i7Íú\x03IHbÄIʲ#ë]öQw\x06[=12=]..."
呃。
而且不只是 Google。 http-get
通过我的 phone 网络访问 Stack Overflow 或任何其他网站,结果非常相似。
正在打印该字符串:
...
没有?嗯,好吧。
因子默认为 100% UTF-8。 ISO-8859
应该可以翻译成 UTF-8,事实上,在不使用我的 phone 的互联网时也是如此。
我知道移动服务提供商以在服务内容中注入不良内容而著称。但是如果编码相同,并且 Python 对待它们相同,并且 Python 说它们具有相同的编码...这是怎么回事?
系数为 HEAD
。 Python 是 3.5。笔记本电脑是 Ubuntu 15.10,Android 是 5.1.something,可能最重要的是,我的移动服务提供商是 StraightTalk。
如 Python 演示所示,我通常不会遇到页面内容问题。
https://github.com/factor/factor/issues/1589
没想到要看headers。
答案?
content-encoding: Accept-Encoding
在普通 WiFi 上。
content-encoding: gzip
在热点上。
现在如何用Factor解压是另一个问题了。
我很聪明phone。在这个 smartphone 上,我有一个移动热点,本质上是一个便携式 WiFi 网络,可以将我的 phone 的互联网访问通过管道传输到我的笔记本电脑。
在我的笔记本电脑上,我有 Python 3 和 requests library。这里使用 Python 并请求获取 google.com
,以及我的 phone 的热点。 (结果与使用 "real wifi" 完全相同。)
>>> x = requests.get("http://google.com")
>>> x.apparent_encoding; x[:100]
'ISO-8859-2'
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content'
好!一切都在按计划进行。
也在我的笔记本电脑上,我有 Factor,它在标准库中有一个易于使用的 wgetter。 http-get
在 "normal" WiFi 网络上工作。
IN: scratchpad "http://google.com" http-get nip
--- Data stack:
"<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org..."
成功!
嗯,不。 http-get
在我的 phone 的热点上:
IN: scratchpad "http://google.com" http-get nip
--- Data stack:
"\x1f\b[=12=][=12=][=12=][=12=][=12=][=12=]\x03Å<ëzÛ¶ÿÏSÐH+K+\"u\x17eÚ&iâÓ¤Ik§i7Íú\x03IHbÄIʲ#ë]öQw\x06[=12=]..."
呃。
而且不只是 Google。 http-get
通过我的 phone 网络访问 Stack Overflow 或任何其他网站,结果非常相似。
正在打印该字符串:
...
没有?嗯,好吧。
因子默认为 100% UTF-8。 ISO-8859
应该可以翻译成 UTF-8,事实上,在不使用我的 phone 的互联网时也是如此。
我知道移动服务提供商以在服务内容中注入不良内容而著称。但是如果编码相同,并且 Python 对待它们相同,并且 Python 说它们具有相同的编码...这是怎么回事?
系数为 HEAD
。 Python 是 3.5。笔记本电脑是 Ubuntu 15.10,Android 是 5.1.something,可能最重要的是,我的移动服务提供商是 StraightTalk。
如 Python 演示所示,我通常不会遇到页面内容问题。
https://github.com/factor/factor/issues/1589
没想到要看headers。
答案?
content-encoding: Accept-Encoding
在普通 WiFi 上。
content-encoding: gzip
在热点上。
现在如何用Factor解压是另一个问题了。