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/ ...
随机推荐
- vue框架08 vue3
vue3的介绍 # vue项目的版本,新项目使用vue3,部分老项目使用vue2 # vue3的变化 1.性能的提升 - 打包大小减少41% - 初次渲染快55%,更新渲染块133% - 内存减少54 ...
- js把一个数组的数据平均到几个数组里面
arr 原始数组数据 count 每个数组里面元素个数 function splitIpLit(arr,count) { let i = 0; let newArr = []; while(i &l ...
- ts 学习笔记
var message:string = "Hello World" console.log(message) // ts 1基础类型 任意类型 any 声明为 any 的变量可以 ...
- 088_BatchApex_Callout
global class BatchSync implements Database.Batchable<sObject>, Database.AllowsCallouts { publi ...
- MTSC2021上海站PPT 分享
- vue组件自调用
组件自调用 在vue中有些情况下我们会用到组件本身来遍历出自己想要的效果. 其实非常简单,可以在模板中使用name属性值,来调用自己 <template> <el-submenu v ...
- Java基础学习:4、类和对象及方法
类:事物的描述.是具备某些共同特征的实体的集合,它是一种抽象的数据类型,它是对所具有相同特征实体的抽象. 对象:该类事物的实例.在Java中通过new进行创建.是一个真实世界中的实体.对象是一种个性的 ...
- flutter 常用ui库
1,EasyRefresh实现listview上拉刷新下拉加载,添加头尾布局,以及加载样式 地址:https://pub.flutter-io.cn/packages/flutter_easyrefr ...
- linux与windows互通
https://www.cnblogs.com/zhouby/p/10724149.html
- You are using pip version 8.1.2, however version 23.0 is available.You should consider upgrading via the 'pip install --upgrade pip' command.
今天使用python2安装es模块时报错: 原因是pip(模块管理工具)版本过低,需先升级pip,再进行安装 先替换pip的镜像,默认镜像拉取慢,还可能会失败 cd ~;mkdir .pip;touc ...