当前位置:网站首页>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" />在每一个标签末尾加上“/”号
成功执行:
完
边栏推荐
- [转]MySQL操作实战(一):关键字 & 函数
- Service fusing hystrix
- [LeetCode] 整数反转【7】
- YOLOv5添加注意力機制
- Solon Logging 插件的添加器级别控制和日志器的级别控制
- A complete attack chain
- 2022上半年全国教师资格证下
- Research on the value of background repeat of background tiling
- [allocation problem] 135 Distribute candy
- Embedded database development programming (VI) -- C API
猜你喜欢

2022年上半年国家教师资格证考试

The present is a gift from heaven -- a film review of the journey of the soul

win10虚拟机集群优化方案

Collapse of adjacent vertical outer margins

Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!

BUUCTF MISC
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction

Bucket sort

Data is stored in the form of table

一个新的微型ORM开源框架
随机推荐
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
Haut OJ 1245: large factorial of CDs --- high precision factorial
Reverse one-way linked list of interview questions
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
Count sort
Listview pull-down loading function
Cocos2dx screen adaptation
Solon 框架如何方便获取每个请求的响应时间?
[allocation problem] 135 Distribute candy
Do a small pressure test with JMeter tool
What is the agile proportion of PMP Exam? Dispel doubts
2022/7/2 question summary
Kali 2018 full image download
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research
Programmers' experience of delivering takeout
UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
To be continued] [UE4 notes] L4 object editing
Cocos2dx Lua registers the touch event and detects whether the click coordinates are within the specified area
《动手学深度学习》学习笔记
嵌入式数据库开发编程(六)——C API


