python - 我的移动网络对编码有何影响?

标签 python encoding factor-lang

<分区>

我有一部智能手机。在这部智能手机上,我有一个移动热点,本质上是一个可移植 WiFi 网络,可将我手机的互联网访问通过管道传输到我的笔记本电脑。

在我的笔记本电脑上,我有 Python 3 和 requests library .这里使用 Python 并请求通过我手机的热点获取 google.com。 (结果与使用“真实 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。这是在“普通”WiFi 网络上工作的http-get

IN: scratchpad "http://google.com" http-get nip

--- Data stack:
"<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org..."

成功!

嗯,不。 http-get 在我手机的热点上:

IN: scratchpad "http://google.com" http-get nip

--- Data stack:
"\x1f\b\0\0\0\0\0\0\x03Å<ëzÛ¶ÿÏSÐH+K+\"u\x17eÚ&iâÓ¤Ik§i7Íú\x03IHbÄIʲ#ë]öQw\x06\0..."

呃。
而且不仅仅是谷歌。 http-getting Stack Overflow 或我手机网络上的任何其他网站都给出了非常相似的结果。

打印那个字符串:

enter image description here

...

没有?嗯,好的。


因子默认为 100% UTF-8。 ISO-8859 应该可以转换为 UTF-8,事实上,当我不使用手机的互联网时也是如此。

我知道移动服务提供商以将不良内容注入(inject)服务内容而著称。但是,如果编码相同,Python 对它们的处理方式相同,并且 Python 说它们具有相同的编码……这是怎么回事?


因素是 HEAD。 Python 是 3.5。笔记本电脑是 Ubuntu 15.10,Android 是 5.1.something,可能最重要的是,我的移动服务提供商是 StraightTalk。

如 Python 演示所示,我通常不会遇到页面内容问题。

最佳答案

https://github.com/factor/factor/issues/1589

我没想过要看标题。

答案是什么?

content-encoding:在普通 WiFi 上接受编码

content-encoding: gzip 在热点上。

现在如何用Factor解压是另一个问题。

关于python - 我的移动网络对编码有何影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36230157/

相关文章:

compilation - 编译因子程序的更快方法

python - Django 外键创建

jquery - 使用MVC3的HTML编码和解码

python - 使用 minit ='matrix' 时,scipy 的 kmeans2 算法是否也会权衡初始质心集?

Python显示特殊字符

python - python 中的 iso-8859-1 和 utf8

factor-lang - 使用 Factor 读取文件时如何等待更多内容?

python - 从 Spark GroupedData 对象中选择随机项

python - 根据每个组的频率添加一列