报错分析:

我们检查代码没有任何问题,但报错显示:开始和结束标记不匹配。

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")
&#13:这是换行符,这个没有影响



lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 4 and head, line 6, column 12 报错分析与解决方案的更多相关文章

  1. 报错分析---->jsp自定义标签:Unable to load tag handler class

    Unable to load tag handler class 无法加载标签处理程序类 处理自定义标签的类中如下: 调用自定义标签的jsp中如下:

  2. lxml.etree.HTML(text) 解析HTML文档

    0.参考 http://lxml.de/tutorial.html#the-xml-function There is also a corresponding function HTML() for ...

  3. 【译】:lxml.etree官方文档

    本文翻译自:http://lxml.de/tutorial.html, 作者:Stefan Behnel 这是一个关于使用lxml.etree进行XML处理的教程.它简要介绍了ElementTree ...

  4. 在MacOS下Python安装lxml报错xmlversion.h not found 报错的解决方案

    最近在看一个自动化测试框架的问题,需要用到Lxml库,下载lxml总是报错. 1,使用pip安装lxml pip install lxml 2,然后报错了,报错内容是: In file include ...

  5. 【python】python安装lxml报错【2】

    cl : Command line warning D9025 : overriding '/W3' with '/w' lxml.etree.c c:\docume~\admini~.chi\loc ...

  6. 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 ...

  7. 163源报错Hash Sum mismatch 解决方法

    Ubuntu server 用的163的源,报错: W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-updates/mai ...

  8. 【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 ...

  9. tomcat部署新的项目的时候出现报错信息: Invalid byte tag in constant pool: 15

    上面一堆tomcat启动的提示信息省略掉,下面是报错的具体信息:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid ...

  10. 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/ ...

随机推荐

  1. centos7.8GPU服务器搭建

    首先官方文档有cuda驱动和toolkit和Linux内核本,gcc版本的对应关系,其中也有一些安装过程可参考: https://developer.nvidia.com/cuda-toolkit-a ...

  2. 新的学习历程-python1 Hello World

    1 print('hello world!') 2 if 2 > 0: 3 print('ok') 4 print('yes') 5 6 x = 3; y = 4 7 print(x + y) ...

  3. 浅谈storm

    storm分布式,可容错的实时计算框架,低延迟能做到毫秒级的响应,storm进程是常驻内存,Hadoop是不断启停的,storm中的数据不经过磁盘,都在内存中,处理完成后就没有了,但是可以写到数据库中 ...

  4. WinForms 嵌入 Web服务

    1.首先安装一个Kestrel服务器包 Microsoft.AspNetCore.Server.Kestrel 2.在Main方法中插入如下代码 static class Program { /// ...

  5. python + unittest + request + parameterized 参数化遇到中文名称testcase不显示的问题

    最近使用python+unittest+request+parameterized做接口测试,然后在利用parameterized做参数化时,发现测试用例的中文名称,感觉很奇怪,于是跟踪了parame ...

  6. Spark应用程序第三方jar文件依赖解决方案

    第一种方式 操作:将第三方jar文件打包到最终形成的spark应用程序jar文件中 应用场景:第三方jar文件比较小,应用的地方比较少 第二种方式 操作:使用spark-submit提交命令的参数: ...

  7. GUI程序中使用Write语句调试

    Lazarus GUI程序中使用Write语句调试 比如像VB 下的 Debug.print 可直接在立即窗口中打印出调试内容 其实可以使用 WriteLn('XXXX ', XXX); Write( ...

  8. 将【jar包、bat、其他文件】注册到windows服务的三种方法

    将[jar包.bat.其他文件]注册到windows服务的三种方法 1.instsrv.exe和srvany.exe 1.下载配置instsrv和srvany 下载地址:https://dl.pcon ...

  9. 李光耀观天下.PDF

    书本详情 李光耀观天下作者: 李光耀出版社: 北京大学出版社原作名: 李光耀观天下出版年: 2015-6页数: 299装帧: 平装ISBN: 978730125751

  10. 实验一-Password engine-加密API研究

    加密API研究 181210 一.列举API在编程中的使用方式 GMT 0016-2012 类型定义 typedef struct Struct_DEVINFO{ VERSION Version; C ...