![](/img/trans.png)
[英]Some HTML data is missing when I am trying to do webscraping using BeautifulSoup
[英]I am trying to get html data from a site using urllib but for some sites i am ending up with some unknown characters in python
嘿家伙我试图从网站使用urllib.openurl.read()获取html数据,但对于一些网站,我得到的是数据链接* 6 \\ xbdW \\ xb6 \\ xd6 \\ xff \\ xca \\ x9d \\ x9bO | \\ xc0 \\ x96a \\ xc7 \\ xc8 \\ xf7 \\ xa7 \\ x10- \\ x8aM {\\ xf8 \\ x *并且我不知道它是什么以及为什么我会这样。 我试着谷歌搜索一些说有编码解码问题我试过,但你可以看到没有运气那么请指导我在这黑暗中。 这是我的代码--->
url = "http://mangafox.me/manga/online_the_comic/c001/1.html" # for this site and some more its not working
page = urllib.urlopen(url).read()
print page
你知道打印这段代码后发生了什么。
这个页面是gzip格式的,你需要在获取数据之前解压缩:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)
代码开头的0x8b表示gzip格式。
你应该看看这个问题:
twitter trend api UnicodeDecodeError:'utf8'编解码器无法解码位置1的字节0x8b:意外的代码字节
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.