当前位置:网站首页>lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
2022-07-05 05:19:00 【星与梦想star_dream】
Python爬虫中遇到的问题:
Python代码(本身没有错,是HTML文档有问题)
from lxml import etree # 获取本地HTML文档 html = etree.parse(r"测试.html") result = etree.tostring(html, encoding='utf-8').decode('utf-8') print(result)HTML文档(出错信息)
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>etree的parse方法</title> </head> <body> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> </ul> </body> </html>
解决方案:
重点修改该部分
修改后:
<meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />在每一个标签末尾加上“/”号
成功执行:
完
边栏推荐
- YOLOv5-Shufflenetv2
- Haut OJ 1321: mode problem of choice sister
- UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
- Unity check whether the two objects have obstacles by ray
- JVM call not used once in ten years
- 2022/7/2做题总结
- Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
- Romance of programmers on Valentine's Day
- PMP考试敏捷占比有多少?解疑
- Lua GBK and UTF8 turn to each other
猜你喜欢

Collapse of adjacent vertical outer margins
![[转]MySQL操作实战(三):表联结](/img/70/20bf9b379ce58761bae9955982a158.png)
[转]MySQL操作实战(三):表联结
![[to be continued] [UE4 notes] L3 import resources and project migration](/img/81/6f75f8fbe60e037b45db2037d87bcf.jpg)
[to be continued] [UE4 notes] L3 import resources and project migration

C language Essay 1

质量体系建设之路的分分合合

Binary search basis

Improvement of pointnet++
![[to be continued] [depth first search] 547 Number of provinces](/img/c4/b4ee3d936776dafc15ac275d2059cd.jpg)
[to be continued] [depth first search] 547 Number of provinces

嵌入式数据库开发编程(五)——DQL

Generate filled text and pictures
随机推荐
[binary search] 34 Find the first and last positions of elements in a sorted array
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
[turn]: OSGi specification in simple terms
2022/7/1學習總結
Unity enables mobile phone vibration
嵌入式数据库开发编程(六)——C API
Listview is added and deleted at the index
使用命令符关闭笔记本自带键盘命令
Solon Logging 插件的添加器级别控制和日志器的级别控制
Count sort
Romance of programmers on Valentine's Day
Unity writes timetables (without UI)
Kali 2018 full image download
Vs2015 secret key
PMP考试敏捷占比有多少?解疑
Unity shot tracking object
FVP和Juno平台的Memory Layout介绍
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
[depth first search] 695 Maximum area of the island
Cocos2dx screen adaptation


