报错分析:

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

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. 20230103~05code

    目录 U190849 最简分式 P5734 [深基6.例6]文字处理软件 P1104 生日 P4305 [JLOI2011]不重复数字 P8218 [深进1.例1]求区间和 P3397 地毯 P236 ...

  2. ERROR StatusLogger No Log4j 2 configuration file found

    ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only er ...

  3. SAP 后台任务定时job

    定时任务的事务码 sm36:创建定时任务 sm37:查看定时任务 JDBG:后台任务debug,在对应的sm37中对应的job页面 t-code输入 创建定时任务SM36 名称可以随便起 一般都是按自 ...

  4. iOS设备和模块解耦-方案对比

     问题: 第一点,我们的设备之间,通过设备类型进行区分,然后分别跳转到不同的界面.导致不同设备会对同一个类别进行操作. 就会造成代码耦合,后续对类别进行增删改就会导致并行开发中容易出现代码冲突或者代码 ...

  5. GBDT初识

    GBDT的决策树: ​ 无论是处理回归任务还是二分类以及多分类任务,GBDT使用的决策树是CART回归树.因为GBDT每次迭代要拟合的是梯度值,是连续值所以要用回归树. ​ 对于回归树算法来说最重要的 ...

  6. 使用svg让页面自适应浏览器大小,整体等比缩放

    网页代码: <!DOCTYPE html> <html> <head> <style> body { margin:0; padding:0; widt ...

  7. unittestreport生成报告介绍

    ​ unittestreport主要有以下几个作用 接口用例HTML 测试报告生成. 测试用例失败重运行. 发送测试结果及报告到邮箱. 发送报告到钉钉群. 安装unittestreport: pip3 ...

  8. k8s暂停一个pod

    模拟k8s暂停一个服务:kubectl scale --replicas=0 deployment/[deployment]  -n [namespace](如要恢复设置参数--replicas=1即 ...

  9. Linux 升级 gcc g++

    Linux 升级 gcc g++ Centos7 上升级 gcc g++ # yum -y install centos-release-scl # yum -y install devtoolset ...

  10. openframeworks 设置不显示控制台窗口

    1.设置Linker 下的System->选择Windows 2.设置入口函数,然后编译就可以了 int APIENTRY wWinMain(_In_ HINSTANCE hInstance, ...