当前位置:网站首页>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" />在每一个标签末尾加上“/”号
成功执行:
完
边栏推荐
- 64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
- Solon 框架如何方便获取每个请求的响应时间?
- 嵌入式数据库开发编程(零)
- Haut OJ 1316: sister choice buys candy III
- Double pointer Foundation
- SDEI初探-透过事务看本质
- Lua wechat avatar URL
- A three-dimensional button
- django连接数据库报错,这是什么原因
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
猜你喜欢

Binary search basis

Research on the value of background repeat of background tiling

To the distance we have been looking for -- film review of "flying house journey"

Applet live + e-commerce, if you want to be a new retail e-commerce, use it!

Learning notes of "hands on learning in depth"
![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
[interval problem] 435 Non overlapping interval

Web APIs DOM节点
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction

BUUCTF MISC

Heap sort summary
随机推荐
[allocation problem] 455 Distribute cookies
Haut OJ 1350: choice sends candy
YOLOv5添加注意力機制
The next key of win generates the timestamp file of the current day
2022/7/2做题总结
[转]MySQL操作实战(一):关键字 & 函数
Grail layout and double wing layout
2022/7/2 question summary
UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
[speed pointer] 142 circular linked list II
Optimization scheme of win10 virtual machine cluster
Data is stored in the form of table
Simple HelloWorld color change
What is the agile proportion of PMP Exam? Dispel doubts
Bucket sort
[LeetCode] 整数反转【7】
C language Essay 1
Dotween usage records ----- appendinterval, appendcallback
Unity intelligent NPC production -- pre judgment walking (method 1)
Improvement of pointnet++


