lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 4 and head, line 6, column 12 报错分析与解决方案
报错分析:
我们检查代码没有任何问题,但报错显示:开始和结束标记不匹配。
html:因为html是超文本标记语言,代码不规范也能解析。
python:python是编程语言,代码不规范则解析不了。

解决方案:
我们只要给python指定解析器,他是不是能解析出网页呢?
parser = etree.HTMLParser(encoding="utf-8") #parser:解析器。文件名+网页类型+解析器(指定编码)
把parser解析器放到tree = etree.parse("b.html")里面:tree = etree.parse("b.html", parser=parser)
运行:

指定类型解码:etree.tostring(tree, encoding="utf-8").decode("utf-8")

:这是换行符,这个没有影响

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 4 and head, line 6, column 12 报错分析与解决方案的更多相关文章
- 报错分析---->jsp自定义标签:Unable to load tag handler class
Unable to load tag handler class 无法加载标签处理程序类 处理自定义标签的类中如下: 调用自定义标签的jsp中如下:
- lxml.etree.HTML(text) 解析HTML文档
0.参考 http://lxml.de/tutorial.html#the-xml-function There is also a corresponding function HTML() for ...
- 【译】:lxml.etree官方文档
本文翻译自:http://lxml.de/tutorial.html, 作者:Stefan Behnel 这是一个关于使用lxml.etree进行XML处理的教程.它简要介绍了ElementTree ...
- 在MacOS下Python安装lxml报错xmlversion.h not found 报错的解决方案
最近在看一个自动化测试框架的问题,需要用到Lxml库,下载lxml总是报错. 1,使用pip安装lxml pip install lxml 2,然后报错了,报错内容是: In file include ...
- 【python】python安装lxml报错【2】
cl : Command line warning D9025 : overriding '/W3' with '/w' lxml.etree.c c:\docume~\admini~.chi\loc ...
- VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper
Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...
- 163源报错Hash Sum mismatch 解决方法
Ubuntu server 用的163的源,报错: W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-updates/mai ...
- 【MySQL】InnoDB: Error: checksum mismatch in data file 报错
参考:http://www.jb51.net/article/66951.htm 用5.7版本启动原5.5实例后,再用5.5启动出现以下报错 InnoDB: Error: checksum misma ...
- tomcat部署新的项目的时候出现报错信息: Invalid byte tag in constant pool: 15
上面一堆tomcat启动的提示信息省略掉,下面是报错的具体信息:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid ...
- cocos2dx在Eclipse下编译报错:Cannot find module with tag 'CocosDenshion/android' in import path
在Eclipse下编译cocos2dx项目,报错如下: Android NDK: jni/Android.mk: Cannot find module with tag 'CocosDenshion/ ...
随机推荐
- 【剑指Offer】【数组】数组中出现次数超过一半的数字
题目:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2.如果 ...
- 了解ASP(三) -- Cookie, Session, Application
ASP一共内建了7个对象,有Session.Application.Cookie.Response.Request.Server,这些对象都可以直接使用. 1. 什么是 Cookie? 1. cook ...
- 上传图片到Mongo数据库;从Mongo数据库下载图片显示到前端
/** * 上传一个图片文件,保存到mongo数据库中 * @param doc * @param parent 文件所在的目录 * @param request * @return */ @Post ...
- uniapp 开发遇到的问题
1. App平台IOS端软键盘上方横条去除方案(禁用键盘上的^) 在 pages.json 中配置 style配置 "app-plus": { "softinputNav ...
- ASP.NET Core http请求内容过大, IIS服务器 返回 Request Too Long 解决方案
1.修改web.config文件内容如下: <?xml version="1.0" encoding="utf-8"?> <configura ...
- 八、常用Api
Object 深拷贝和浅拷贝 Objects 包装类 StringBuilder StringJoin Math System RuntimeBigDecimal Date SImpleDateFor ...
- Visual Studio Code 使用总结
记录一下个人在使用 VS Code 中的一些插件和设置. 该配置在编写 vue + iview 项目时使用. 文件路径 用户文件路径:%AppData%/Code/User 用户设置:sett ...
- win10上打包的qt程序放到win7上打不开的解决方法
在win 10 上编写并打包发布了qt5.12.3 msvc2017 32bit的qt程序,在其他win10 电脑上都能正常运行,但是放到win7电脑上,运行exe时依次出现缺少"msvcp ...
- python菜鸟学习: 13. excel文件编辑openpyxl使用
#1. xls文件转换成xlsx文件,需要使用到 win32com from win32com import client as wc filepath = "D:\\python\\liy ...
- 【Word】如何批量导出ppt中的备注
[Word]如何批量导出ppt中的备注 文件 | 导出 | 创建讲义 | 备注在幻灯片旁 在word中删除左边两列,复制剩下的表格 | 粘贴-只保留文本