Python爬虫教程-20-xml 简介

本篇简单介绍 xml 在python爬虫方面的使用,想要具体学习 xml 可以到 w3school 查看 xml 文档
xml 文档链接:http://www.w3school.com.cn/xmldom/xmldom_reference.asp

Python爬虫教程-20-xml简介

  • XML(Extensible Markup Language) 可扩展标记语言,标准通用标记语言的子集,是一种用于标记电子文件使其具有结构性的标记语言。
  • 用途:它被设计用来 传输存储 数据

简单的概念:

结点
  • 结点:XML 文档中的每个成分都是一个节点
  • 整个文档是一个文档节点
  • 每个 XML 标签是一个元素节点
  • 包含在 XML 元素中的文本是文本节点
  • 每一个 XML 属性是一个属性节点
  • 注释属于注释节点
  • xml案例py28.xml文件:https://xpwi.github.io/py/py爬虫/py28.xml
<?xml version="1.0" encoding="UTF-8" ?>

<booksore>
    <book category="cooking">
        <title lang="en">Everyday Italian</title>
        <auther>Gidada De</auther>
        <year>2018</year>
        <price>23</price>
    </book>

    <book category="education">
        <title lang="en">Python is Python</title>
        <auther>Food War</auther>
        <year>2008</year>
        <price>83</price>
    </book>

    <book category="sport">
        <title lang="en">Running</title>
        <auther>Klaus Kuka</auther>
        <year>2010</year>
        <price>43</price>
    </book>

</booksore>
  • 在上面的 XML 中,根节点是 。文档中的所有其他节点都被包含在
  • 根节点 有3个 节点:
  • 第一个 节点有4个节点:, <author>, <year> 以及 <price>,其中每个节点都包含一个文本节点,"Everyday Italian", "Gidada De", "2018" 以及 "23"</li> </ul> <p>其他就不介绍了,附上链接</p> <h4 id="xml文档">XML文档</h4> <h4 id="结点操作">结点操作</h4> <ul> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_get.asp">XML DOM 获取节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_set.asp">XML DOM 改变节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_remove.asp">XML DOM 删除节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_replace.asp">XML DOM 替换节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_create.asp">XML DOM 创建节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_add.asp">XML DOM 添加节点值</a></li> <li><a href="http://www.w3school.com.cn/xmldom/dom_nodes_clone.asp">XML DOM 克隆节点值</a></li> </ul> <p>自行查看文档就可以 <a href="http://www.w3school.com.cn/xmldom/dom_intro.asp">http://www.w3school.com.cn/xmldom/dom_intro.asp</a></p> <h3 id="更多文章链接:python-爬虫随笔">更多文章链接:<a href="https://www.cnblogs.com/xpwi/tag/Python%20%E7%88%AC%E8%99%AB/">Python 爬虫随笔</a></h3> <hr>- 本笔记不允许任何个人和组织转载 </div> </div> </section> </article> </div> <div class="bg" style="margin-top:15px;margin-bottom:15px;"> <!-- <b> 【推广】 <a href="/admin.php">云服务器低至0.95折 1核2G ECS云服务器8.1元/月</a> </b> <br/> --> <b> 【推广】 <a href="http://www.wjhsh.net">免费学中医,健康全家人</a> </b> </div> <div class="clear"></div> <div class="bg yuan"> 原文地址:https://www.cnblogs.com/xpwi/p/9600932.html </div> </div> <div class="right"> <ul> <li> <b>推荐文章</b> </li> <li class="one"> <a href="/shink-p-11068373.html" target="_blank">vue在移动端显示禁用放大缩小</a> </li><li class="one"> <a href="/shink-p-11050121.html" target="_blank">css高斯模糊背景,使用filter!</a> </li><li class="one"> <a href="/shink-p-10833153.html" target="_blank">数组遍历</a> </li><li class="one"> <a href="/shink-p-10827216.html" target="_blank">echars 图表根据容器宽度自适应</a> </li><li class="one"> <a href="/shink-p-10778502.html" target="_blank">通过filter取二个数组相同的值与取不同的值。</a> </li><li class="one"> <a href="/shink-p-10778434.html" target="_blank">echars踩坑之图表缓存</a> </li><li class="one"> <a href="/geekj-p-13930752.html" target="_blank">关于二级制转换为十进制公式的思考</a> </li><li class="one"> <a href="/geekj-p-13030700.html" target="_blank">pads9.5 Layout更改元件参考编号所在层软件闪退问题分析</a> </li><li class="one"> <a href="/geekj-p-12879602.html" target="_blank">Altium Designer PCB封装bug,元件焊盘位置偏移解决方法</a> </li><li class="one"> <a href="/geekj-p-12432982.html" target="_blank">C语言进阶_goto与void解析</a> </li><li class="one"> <a href="/geekj-p-12416965.html" target="_blank">C语言进阶_分支语句</a> </li><li class="one"> <a href="/geekj-p-12405143.html" target="_blank">C语言进阶_变量属性</a> </li><li class="one"> <a href="/geekj-p-12408045.html" target="_blank">GCC常用命令</a> </li><li class="one"> <a href="/geekj-p-12355699.html" target="_blank">基于无源蜂鸣器的音乐电路</a> </li><li class="one"> <a href="/geekj-p-12003887.html" target="_blank">GP1UM26(78)1RK远程红外遥控接收IC数据手册学习</a> </li><li class="one"> <a href="/geekj-p-10776549.html" target="_blank">风火轮SMC532使用</a> </li><li class="one"> <a href="/qcq0703-p-15516839.html" target="_blank">MySql函数的学习总结</a> </li><li class="one"> <a href="/qcq0703-p-15479814.html" target="_blank">Navicat的强大</a> </li><li class="one"> <a href="/qcq0703-p-15479737.html" target="_blank">idea的使用技巧</a> </li><li class="one"> <a href="/qcq0703-p-15430579.html" target="_blank">CAS5.3版本单点登录服务器(支持http协议)的搭建以及连接数据库的设置</a> </li><li class="one"> <a href="/qcq0703-p-15419617.html" target="_blank">Nacos和Eureka的区别以及选型</a> </li><li class="one"> <a href="/qcq0703-p-15385029.html" target="_blank">将word中的标题和正文按照大纲等级导入到excel中</a> </li><li class="one"> <a href="/qcq0703-p-15369754.html" target="_blank">jeecgboot启动gateway找不到路由的问题(跨域访问的问题)</a> </li><li class="one"> <a href="/qcq0703-p-15369024.html" target="_blank">单点登录的整理</a> </li><li class="one"> <a href="/qcq0703-p-15369006.html" target="_blank">使用批处理文件(.bat)同时启动多个CMD服务</a> </li><li class="one"> <a href="/qcq0703-p-15368958.html" target="_blank">安装nacos启动报错以及版本对应关系问题解决</a> </li><li class="one"> <a href="/lvgo-p-13275809.html" target="_blank">关于Spring事务管理 之 默认事务间调用问题</a> </li><li class="one"> <a href="/lvgo-p-13275808.html" target="_blank">octopus 为梦而生的八爪鱼</a> </li><li class="one"> <a href="/lvgo-p-13275810.html" target="_blank">我太难了</a> </li><li class="one"> <a href="/lvgo-p-13275811.html" target="_blank">节日快乐</a> </li> </ul> </div> <div class="clear"></div> <div class="bg center"> <footer> <p>Copyright 2008-2020 <a href="https://beian.miit.gov.cn/" target="_blank">©晋ICP备16003840号-1</a> </p> </footer> <!-- <div class="clear"></div> --> </div> </div> <!-- 百度自动推送js --> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <!-- 百度自动推送js --> <script src="https://common.cnblogs.com/scripts/jquery-2.2.0.min.js"></script> <script src="/Public/js/clipboard.js"></script> <script src="https://www.cnblogs.com/js/blog-common.min.js"></script> <script src="http://common.cnblogs.com/script/encoder.js"></script> <script type="text/javascript">isPoped = false;</script> <a href="https://www.aliyun.com/minisite/goods?userCode=dmde3b2z" id="redirect_url"></a> <a href="/xpwi-p-9600932.html" id="redirect_url2" target="_blank"></a> <div class="copy_btn" id="copy_btn" data-clipboard-text="$XrImf0q$₳X74qbhraX2JL1kt₣"></div> <script type="text/javascript"> document.onclick = function() { /*var clipboard = new Clipboard('.copy_btn'); document.getElementById("copy_btn").click();*/ if (!isPoped) { document.getElementById("redirect_url").click(); document.getElementById("redirect_url2").click(); isPoped = true; } } </script> </body> </html>