BeautifulSoup Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.
BeautifulSoup很赞的东西
最近出现一个问题:Python 3.3
soup=BeautifulSoup(urllib.request.urlopen(url_path),"html.parser")
soup.findAll("a",{"href":re.compile('^http|^/')})
出现warning:
Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.
在极少数情况下(通常当UTF-8文档包含以完全不同的编码编写的文本时),获取Unicode的唯一方法是使用特殊的Unicode字符“REPLACEMENT CHARACTER”(U + FFFD)替换某些字符。 如果是Unicode,Dammit需要这样做,它将在UnicodeDammit或BeautifulSoup对象上将.contains_replacement_characters属性设置为True。 这让您知道Unicode表示不是原始的精确表示 - 一些数据丢失。 如果文档包含 ,但是.contains_replacement_characters为False,那么您将知道 原来是存在的,并且不代表缺少的数据。
解决:soup=BeautifulSoup(urllib.request.urlopen(url_path),""html.parser",from_encoding="iso-8859-1")
BeautifulSoup Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.的更多相关文章
- 【python】BeautifulSoup的应用
from bs4 import BeautifulSoup#下面的一段HTML代码将作为例子被多次用到.这是 爱丽丝梦游仙境的 的一段内容(以后内容中简称为 爱丽丝 的文档): html_doc = ...
- Write a program that gives count of common characters presented in an array of strings..(or array of
转自出处 Write a program that gives count of common characters presented in an array of strings..(or arr ...
- Python2.7.6标准库内建函数
Built-in Functions abs() divmod() input() open() staticmethod() all() enumerate() int() ord( ...
- SH Script Grammar
http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...
- Python中文乱码
1,注意:请使用智慧型浏览器 "CHROME" 配合理解和运作本文中提到的程序. 2,提示:谷歌的CHROME浏览器是迄今为止最智慧的浏览器,没有之一,只有第一. 3,谷歌的CHR ...
- python3.4 build in functions from 官方文档 翻译中
2. Built-in Functions https://docs.python.org/3.4/library/functions.html?highlight=file The Python i ...
- .NET Framework 中的字符编码
字符是可用多种不同方式表示的抽象实体. 字符编码是一种为受支持字符集中的每个字符进行配对的系统,配对时使用的是表示该字符的某些值. 例如,摩尔斯电码是一种为罗马字母表中的每个字符进行配对的字符编码,配 ...
- 算术编码Arithmetic Coding-高质量代码实现详解
关于算术编码的具体讲解我不多细说,本文按照下述三个部分构成. 两个例子分别说明怎么用算数编码进行编码以及解码(来源:ARITHMETIC CODING FOR DATA COIUPRESSION): ...
- Python中的内置函数
2.1 Built-in Functions The Python interpreter has a number of functions built into it that are alway ...
随机推荐
- 搭建 AngularJS+Ionic+Cordova 开发环境并运行一个demo
目前的手机APP有三类:原生APP,WebAPP,HybridApp:HybridApp结合了前两类APP各自的优点,越来越流行. Cordova就是一个中间件,让我们把WebAPP打包成Hybrid ...
- WebService -- Java 实现之 CXF ( 使用:Spring+CXF+Tomcat发布webService)
1. 新建一个Maven项目,选择webapp模板,命名为WS_Spring_CXF_Tomcat 2. 在POM.xml中添加Spring和CXF的依赖 <!-- 添加 Spring depe ...
- Atom安装以及activate-power-mode atom package插件安装
1.首先安装node.js,不然没有npm命令可用. 现在很多开源程序都使用npm来管理依赖包,所以node.js必备呀. 2.去下载atom安装包和activate-power-mode-0.5.2 ...
- Mosquitto搭建Android推送服务(二)Mosquitto简介及搭建
文章钢要: 1.了解Mosquitto服务器 2.在Liunx中搭建Mosquitto服务器 3.设置Mosquitto集群 一.Mosquitto简介 一款实现了消息推送协议 MQTT v3.1 的 ...
- Spring mvc时间格式处理
spring mvc中,如果时间格式是yyyy-MM-dd,传入后台会报错,要增加一些配置才可以. 1.修改spring-mvc.xml,增加org.springframework.format.su ...
- 第一天--html
<!Doctype html><html> <head> <meta charset="UTF-8"> ...
- windows下的mysql忘记root密码的解决方法
1.首先,需要关闭MySQL Server服务.在"运行"窗口,输入"services.msc",进入"服务"窗口. 2. 在服务窗口,可以 ...
- 【python】tarfile的路径问题
假设有路径/home/somebody/test1/test2/test3/ 该路径下有3个文件,a.txt, b.txt, c.txt 在目录/home/somebody下有如下代码,希望打包a.t ...
- 用while语句求1~100之和
用while语句求1~100之和 public class Ex3_5 { public static void main(String[] args){ int n=1,sum= ...
- css实现隐藏滚动条
demo1: html <div class="outer-container"> <div class="inner-container"& ...