当前位置:网站首页>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" />在每一个标签末尾加上“/”号
成功执行:
完
边栏推荐
- Optimization scheme of win10 virtual machine cluster
- Page countdown
- 2022上半年全国教师资格证下
- win下一键生成当日的时间戳文件
- Haut OJ 1241: League activities of class XXX
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
- 嵌入式数据库开发编程(六)——C API
- 《动手学深度学习》学习笔记
- The next key of win generates the timestamp file of the current day
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
猜你喜欢

Pointnet++学习

Binary search basis
![[转]MySQL操作实战(三):表联结](/img/70/20bf9b379ce58761bae9955982a158.png)
[转]MySQL操作实战(三):表联结

Page countdown

Ue4/ue5 illusory engine, material part (III), material optimization at different distances

django连接数据库报错,这是什么原因

YOLOv5-Shufflenetv2

Django reports an error when connecting to the database. What is the reason

Double pointer Foundation

Collapse of adjacent vertical outer margins
随机推荐
Development error notes
YOLOv5添加注意力機制
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
Cocos progress bar progresstimer
Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
支持多模多态 GBase 8c数据库持续创新重磅升级
Bubble sort summary
SDEI初探-透过事务看本质
一个新的微型ORM开源框架
Three dimensional dice realize 3D cool rotation effect (with complete source code) (with animation code)
What is the agile proportion of PMP Exam? Dispel doubts
[转]:Apache Felix Framework配置属性
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
[allocation problem] 455 Distribute cookies
Pointnet++学习
[turn]: Apache Felix framework configuration properties
room数据库的使用
Insert sort
Haut OJ 1243: simple mathematical problems
Under the national teacher qualification certificate in the first half of 2022


