使用 xpath 从 HTML 文件中提取 最安全的方法是什么? </h1> <div class="d-flex justify-content-between"> <div> <span class="date text-grey ml-2"> 2024-01-05 </span> </div> <div> </div> </div> </div> </div> <hr /> <div class="message text-break"> <div> <div> <p>这是我当前的 xpath 代码<code>"/html/head/title"</code>.</p> <p>但你知道,在现实世界的 html 环境中,代码格式通常会被破坏,例如<code><html></code>标签丢失可能会导致异常。所以我想知道是否有安全的方法可以提取<code><title></code>标签? (类似于 getElementsByTagName)</p> </div> </div> <br><div> <div> <p><code>"//title"</code>也许?</p> </div> </div> <span style="display:none;" allenmark_388="3508281"></span> </div> <div class="mt-3 text-grey"> 本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@) <span id='ref_question'> </span> </div> <hr> <div class="row"> <div class="col-lg-12 text-muted mt-2"> <i class="icon-tags mr-2"></i> <span class="badge border border-secondary mr-2"> <h2 class="h6 mb-0 small"> <a class="text-secondary" href="/topic/969"> html </a> </h2> </span> <span class="badge border border-secondary mr-2"> <h2 class="h6 mb-0 small"> <a class="text-secondary" href="/topic/6143"> xpath </a> </h2> </span> </div> </div> </div> </div> <div class="d-none threadlist"> <input type="checkbox" name="modtid" value="692388" checked /> </div> <!--<a role="button" class="btn btn-secondary btn-block xn-back col-lg-6 mx-auto mb-3" href="javascript:history.back();">返回</a>--> </div> <div class="card border-0 shadow-sm mb-3 col-lg-3"> <div class="card-header bg-white"> <h3 class="h6 font-weight-400 my-0"> 使用 xpath 从 HTML 文件中提取 <title> 最安全的方法是什么? 的相关文章 </h3> </div> <ul class="list-group list-group-flush"> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000272" class="d-block text-truncate"> 如何显示/隐藏jsf组件 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 在我的一个 JSF 应用程序中 顶部的标题部分包含 selectOneMenu 底部的内容部分显示过滤器组件 默认情况下 应用程序首先在顶部显示 selectOneMenu 数据 在底部显示相应的 Filter 信息 如果用户选择不同的se </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000404" class="d-block text-truncate"> 保存下拉列表中的值 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 这是我的情况 我有 2 页 一页用于选择值 一页用于编辑与该值关联的数据库相关内容 现在 我对如何将从下拉列表中选择的值保存到 PHP 的变量中一无所知 并且已经进行了相当多的研究 有任何想法吗 HTML </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000555" class="d-block text-truncate"> 为什么 Firefox 关闭空 html 标签? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我注意到在 Firefox 中 当我查看源代码时 它会向空标签项添加结束标签 例如 hr and img src image jpg 在 Firefox 中查看源代码我明白了 hr and img src image jpg 该文档是 HT </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000578" class="d-block text-truncate"> 输入字段名称以数字开头 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我有一个输入字段 其名称是 MD5 字符串 例如 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000593" class="d-block text-truncate"> CreateJs Canvas 形状在 Windows Phone 上丢失坐标 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我正在制作一个 Createjs 和 html5 项目 在其中绘制一个形状 红色圆圈 当我单击圆圈时它会发出警报 它在所有台式机和 Android 手机上都能正常工作 除非我在 Windows Phone 中打开它 否则它在普通屏幕上工作正 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000675" class="d-block text-truncate"> HTML/CSS:页面左侧的导航栏 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我发现创建这样具有良好语义的布局很尴尬 左侧是大约 150 像素宽的列 其中包含导航元素 我想将网站这部分的 HTML 放在 HTML 代码的开头 然后有一个简单的方法来强制页面的其余部分不侵占左侧的区域 150 像素列 我考虑过一些选择 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000830" class="d-block text-truncate"> 禁用移动设备上的锚点菜单点击 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我使用嵌套列表作为带有子菜单项的菜单 我曾经这样做过 如果您将鼠标悬停在主菜单项上 子菜单项将通过将显示从无更改为块来出现 我决定让子菜单看起来就像是下拉的 并使用了 CSS 过渡 我遇到的问题是 在第一种方法中 如果您触摸 iPad 上的 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1000850" class="d-block text-truncate"> 检测 html 选择框上的编程更改 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 有没有办法让 HTML 选择元素在每次以编程方式更改其选择时调用函数 当使用 JavaScript 修改选择框中的当前选择时 IE 和 FF 都不会触发 onchange 此外 更改选择的 js 函数是框架的一部分 因此我无法更改它以在结束 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001025" class="d-block text-truncate"> 如何隐藏按钮元素的值? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 如何隐藏按钮的值 同时仍然显示按钮 我使用的颜色 透明 但这行不通 我想隐藏按钮的值 但不是所有按钮的值 我需要将 value 属性保留在按钮中 我只是不想让它被看见 如果您只想显示按钮而不显示任何文本 请将值设置为空字符串 然后手动设置按 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001153" class="d-block text-truncate"> 从 Google Chrome v20 中的日期输入中删除背景箭头 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 自 Google Chrome v20 起 已添加新的日历来输入日期 问题是我正在使用 javascript 创建自己的日历 并且我的图标已经位于与默认镶边箭头相同的位置 我想知道如何删除箭头背景 据我所知 您目前无法禁用它 这里正在进行一 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001301" class="d-block text-truncate"> 使用 HTML 内容对 TextView 进行额外填充 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我有这个TextView </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001374" class="d-block text-truncate"> 行高如何使文本垂直居中? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我试图理解为什么line heightCSS 属性将文本垂直放置在此按钮的中间 btn order width 220px height 58px font size 24px padding 0 text align center ver </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001382" class="d-block text-truncate"> 为什么我会收到此 Javascript 运行时错误? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我的网页上有以下 JavaScript 64 var description new Array 65 description 0 66 description 1 78 function init 79 document getEleme </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001394" class="d-block text-truncate"> 如何让浮动的div对齐到顶部? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 下面的代码可以在这个小提琴中查看 http jsfiddle net VgG55 10 http jsfiddle net VgG55 10 我有以下标记 其中 div 按以下顺序放置 div class wrapper div class </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001463" class="d-block text-truncate"> 禁用 Bootstrap 中的链接 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 第一个例子没有成功 我需要始终有一个列表来禁用链接 或者我的第一个演示有什么问题 a class disabled href Disabled link a ul class nav nav pills li class disabled </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001972" class="d-block text-truncate"> 如何在 Chrome 中实现抓取光标图标? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我知道可以在 Chrome 中使用抓取光标图标 当然是在 Gmail 中 但我不知道如何在我的代码中实现它 我已经尝试过 在CSS中 body cursor grab body cursor webkit grab body cursor </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1001988" class="d-block text-truncate"> 通过 HTML5 文件和 URL API 正确创建和提供 PDF Blob </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 好吧 假设我有文档数据存储在某处 让我们任意取this pdf http www grida no climate ipcc tar wg1 pdf tar 01 pdf 问题 1 我想要做的是对此 URL 进行 AJAX 调用 因为我需要 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1002197" class="d-block text-truncate"> 为什么我的 onclick 事件自动触发 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 加载页面时最初显示 Hello World 我希望它仅在单击按钮后显示 我知道我可以通过向按钮添加内联事件侦听器来做到这一点 我可以只用脚本编写所有这些代码吗 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1002257" class="d-block text-truncate"> 如何仅将网站的特定部分放入 iframe 中? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我只想将网站的一小部分放入 iframe 中 我该怎么做 通常 当我为网站 假设是雅虎 设置 iframe 时 它 会获取整个网站 假设我只想要网站的一小部分 我该怎么做 是否可以在网站的 iframe 上添加边距 我想在我的网站上放置一个 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/1002666" class="d-block text-truncate"> HTML / CSS 如何将图像图标添加到输入类型=“按钮”? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我使用下面的 CSS 但它将图像放在按钮的中心 使用任何方式左对齐或右对齐图标 </div> </li> </ul> </div> <div class="col-lg-12"> <div class="card-header bg-white"> <h3 class="h6 font-weight-bold my-0"> 随机推荐 </h3> </div> <ul class="list-group list-group-flush"> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692369" class="d-block text-truncate" title='如何检查 DataView.RowFilter 中的空白' aria-label='如何检查 DataView.RowFilter 中的空白'> 如何检查 DataView.RowFilter 中的空白 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 假设我有一个名为 A 的列 并且我想检查 A 是否为空或空白 那么使用 DataView 的 RowFilter 进行检查的正确方法是什么 DataTable dt GetData DataView dv new DataView dt d </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692370" class="d-block text-truncate" title='前向声明/何时最好包含标头? [复制]' aria-label='前向声明/何时最好包含标头? [复制]'> 前向声明/何时最好包含标头? [复制] </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 这个问题在这里已经有答案了 我很清楚何时可以 不能使用前向声明 但我仍然不确定一件事 假设我知道我迟早必须包含一个标头才能取消引用 A 类的对象 我不清楚做类似的事情是否更有效 class A class B A a void DoSome </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692371" class="d-block text-truncate" title='Dialogflow Webhook 响应未发送到 Twilio - Twilio 调试器上出现 14103 Invalid Body 错误' aria-label='Dialogflow Webhook 响应未发送到 Twilio - Twilio 调试器上出现 14103 Invalid Body 错误'> Dialogflow Webhook 响应未发送到 Twilio - Twilio 调试器上出现 14103 Invalid Body 错误 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我正在实现一个通过 Twilio 与 WhatsApp 集成的聊天机器人 该机器人使用 V2 API 我已经在 Google 云上实现了集成 因为它们将被关闭 当我从 WhatsApp 触发机器人时 会触发正确的意图并执行正确的功能 但当我 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692372" class="d-block text-truncate" title='如何在 UserControl Paint 事件中对点进行动画处理?' aria-label='如何在 UserControl Paint 事件中对点进行动画处理?'> 如何在 UserControl Paint 事件中对点进行动画处理? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 在绘画事件中 因为我希望能够控制点大小颜色和更多属性 using System ComponentModel using System Drawing using System Drawing Drawing2D public partia </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692373" class="d-block text-truncate" title='在 watir-webdriver 中将 select_list 选项转换为字符串数组?' aria-label='在 watir-webdriver 中将 select_list 选项转换为字符串数组?'> 在 watir-webdriver 中将 select_list 选项转换为字符串数组? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我需要检查选择列表下拉列表的内容 该列表根据另一个字段中的值而变化 我正在将有效选项从 CVS 字段读取到字符串数组中 并通过执行以下操作进行比较 selectContent browser select list id srch stat </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692374" class="d-block text-truncate" title='尝试学习 boost::intrusive Q2' aria-label='尝试学习 boost::intrusive Q2'> 尝试学习 boost::intrusive Q2 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 如果我取消注释这些 BaseList baselist MemberList memberlist 在循环外部并注释掉循环内部的循环 它会崩溃 我需要能够将基本列表 和成员列表 放在任何循环之外 这是如何实现的 Edit 我试图以最简单的形 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692375" class="d-block text-truncate" title='CURL 和 HTTPS,“无法解析主机”' aria-label='CURL 和 HTTPS,“无法解析主机”'> CURL 和 HTTPS,“无法解析主机” </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我正在尝试使用 CURL 获取页面的内容 正在执行获取的页面是 https 它尝试获取的页面也是 https 我尝试的所有设置都收到错误 无法解析主机 c curl init curl setopt c CURLOPT URL url cu </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692376" class="d-block text-truncate" title='Unity 解决方案与 Visual Studio 不兼容' aria-label='Unity 解决方案与 Visual Studio 不兼容'> Unity 解决方案与 Visual Studio 不兼容 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 自从更新到最新版本的 Unity 5 4 0f3 以来 每当我双击脚本时 它都会启动 Visual Studio 和 Monodevelop 但我收到一条错误消息 指出此版本的 VS Community 2015 无法打开我的项目 Mono </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692377" class="d-block text-truncate" title='该进程无法访问该文件,因为该文件正在被另一个进程使用(文件已创建但不包含任何内容)' aria-label='该进程无法访问该文件,因为该文件正在被另一个进程使用(文件已创建但不包含任何内容)'> 该进程无法访问该文件,因为该文件正在被另一个进程使用(文件已创建但不包含任何内容) </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> using System IO class test public static void Main string path c mytext txt if File Exists path File Delete path FileStr </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692378" class="d-block text-truncate" title='生成总和为预定义值的随机数' aria-label='生成总和为预定义值的随机数'> 生成总和为预定义值的随机数 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 所以事情是这样的 我想 例如 生成 4 个伪随机数 加在一起等于 40 这怎么可能是 python 中的圆顶 我可以生成一个随机数 1 40 然后生成 1 和余数之间的另一个数字 等等 但是第一个数字将有更大的机会 抓住 更多 这是标准解决 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692379" class="d-block text-truncate" title='mysql_last_id() 的竞争条件' aria-label='mysql_last_id() 的竞争条件'> mysql_last_id() 的竞争条件 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我花了一天的大部分时间试图找到这个问题的答案 但似乎没有答案 我需要一个函数 它在表中创建一行 从插入的行中检索自动增量 然后使用该值在第二个表中插入另一行 功能上类似于以下 php mysql query INSERT INTO tabl </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692380" class="d-block text-truncate" title='Apache Tomcat v8.0 的下载并安装按钮在 Eclipse 中呈灰色显示' aria-label='Apache Tomcat v8.0 的下载并安装按钮在 Eclipse 中呈灰色显示'> Apache Tomcat v8.0 的下载并安装按钮在 Eclipse 中呈灰色显示 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我希望 Eclipse 下载并安装 Apache Tomcat 服务器环境 但该选项对我来说是灰色的 知道可能缺少什么吗 Eclipse details Eclipse Java EE IDE for Web Developers Vers </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692381" class="d-block text-truncate" title='如何修复 Xcode 10.2 中的“SWIFT_VERSION '3.0'不受支持,支持的版本是:4.0、4.2、5.0”错误?' aria-label='如何修复 Xcode 10.2 中的“SWIFT_VERSION '3.0'不受支持,支持的版本是:4.0、4.2、5.0”错误?'> 如何修复 Xcode 10.2 中的“SWIFT_VERSION '3.0'不受支持,支持的版本是:4.0、4.2、5.0”错误? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我正在尝试运行从应用程序下载的内容 尝试在 Xcode 中打开并出现错误 显示最近的消息 1 不支持 SWIFT VERSION 3 0 支持的版本有 4 0 4 2 5 0 在目标 SimpleWeather 中 在项目中选择目标 Sim </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692382" class="d-block text-truncate" title='React Native GeoLocation 无法在 Android 上运行' aria-label='React Native GeoLocation 无法在 Android 上运行'> React Native GeoLocation 无法在 Android 上运行 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 谁能确认 React Native Geolocation 是否真的可以在 Android 上运行 我在使用时遇到位置请求超时的问题getCurrentPosition 方法 使用时没有错误信息watchPosition method 我已 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692383" class="d-block text-truncate" title='如何运行 docker 容器并在脚本完成后提交更改?' aria-label='如何运行 docker 容器并在脚本完成后提交更改?'> 如何运行 docker 容器并在脚本完成后提交更改? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我想设置一个 cron 作业来在 docker 容器内运行一组命令 然后将更改提交到 docker 映像 我可以将容器作为守护进程运行并使用以下命令获取容器 ID CONTAINER ID sudo docker run d my imag </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692384" class="d-block text-truncate" title='GVim Win32 中仅使用键盘选择列块,或者为什么在包含 mswin.vim 时 Ctrl-Q 不模拟 Ctrl-V?' aria-label='GVim Win32 中仅使用键盘选择列块,或者为什么在包含 mswin.vim 时 Ctrl-Q 不模拟 Ctrl-V?'> GVim Win32 中仅使用键盘选择列块,或者为什么在包含 mswin.vim 时 Ctrl-Q 不模拟 Ctrl-V? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 我希望在 Windows 上使用 Vim 时能够仅使用键盘来选择柱状块 但在 Windows XP 上使用 vim 7 2 时似乎无法这样做 编辑 为了方便起见 最好使用箭头键进行选择 就像其他版本的 vi vim 中通常所做的那样 In </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692385" class="d-block text-truncate" title='C# - 交换不带占位符的对象' aria-label='C# - 交换不带占位符的对象'> C# - 交换不带占位符的对象 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 有人告诉我 使用临时对象并不是交换数组中元素的最有效方法 Such as Object objects new Object 10 Assign the 10 objects some values var Temp objects 2 o </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692386" class="d-block text-truncate" title='Sudo 用户不使用相同的节点版本' aria-label='Sudo 用户不使用相同的节点版本'> Sudo 用户不使用相同的节点版本 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 当我尝试安装软件包时 我的服务器上有一个奇怪的问题npm需要sudo我遇到了问题 我发现我的su和普通用户使用不同的节点版本 node v i get node version 0 10 x 但是当我这样做时 sudo node v i g </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692387" class="d-block text-truncate" title='使用 Left Join 的 Mysql 查询太慢' aria-label='使用 Left Join 的 Mysql 查询太慢'> 使用 Left Join 的 Mysql 查询太慢 </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> Query select r id as id from tbl rls as r left join tblc comment manager as cm on cm rlsc id r id 两个表都有8k条记录 但是为什么速度很慢 有 </div> </li> <li class="list-group-item bg-white"> <h4 class="h6 my-0"> <a href="/article/692388" class="d-block text-truncate" title='使用 xpath 从 HTML 文件中提取 <title> 最安全的方法是什么?' aria-label='使用 xpath 从 HTML 文件中提取 <title> 最安全的方法是什么?'> 使用 xpath 从 HTML 文件中提取 <title> 最安全的方法是什么? </a> </h4> <div class="col-lg-12 text-break text-muted brief mt-2"> 这是我当前的 xpath 代码 html head title 但你知道 在现实世界的 html 环境中 代码格式通常会被破坏 例如标签丢失可能会导致异常 所以我想知道是否有安全的方法可以提取 </div> </li> </ul> </div> <div class="card border-0 rounded shadow-sm mb-3"> <div class="card-header border-0 rounded-top bg-white"> <h3 class="h6 font-weight-400 my-0"> 热门标签 </h3> </div> <ul class="list-unstyled right-font d-flex flex-wrap bg-white px-3 py-2 m-0"> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74837" class="d-block text-truncate right-font"> 面试题目的记录 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74835" class="d-block text-truncate right-font"> 资源泄漏 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74834" class="d-block text-truncate right-font"> 空指针引用 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74833" class="d-block text-truncate right-font"> 前沿技术 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74831" class="d-block text-truncate right-font"> 工作经验 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74830" class="d-block text-truncate right-font"> cdn搭建原理 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74829" class="d-block text-truncate right-font"> php重要技术点 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74828" class="d-block text-truncate right-font"> 面板 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74827" class="d-block text-truncate right-font"> 网页编程 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74826" class="d-block text-truncate right-font"> 项目配置构建部署 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74825" class="d-block text-truncate right-font"> 遇上的各种问题 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74824" class="d-block text-truncate right-font"> esp32相关操作 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74823" class="d-block text-truncate right-font"> antdpro </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74822" class="d-block text-truncate right-font"> DirectX绘制 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74821" class="d-block text-truncate right-font"> d3dUtility </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74820" class="d-block text-truncate right-font"> 绘制立方体 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74819" class="d-block text-truncate right-font"> 普及知识 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74818" class="d-block text-truncate right-font"> 找工作 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74817" class="d-block text-truncate right-font"> LPDDR4协议规范 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74816" class="d-block text-truncate right-font"> 游记 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74815" class="d-block text-truncate right-font"> 敏捷项目管理 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74814" class="d-block text-truncate right-font"> 敏捷看板 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74813" class="d-block text-truncate right-font"> scrum看板 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74812" class="d-block text-truncate right-font"> 敏捷工具 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74811" class="d-block text-truncate right-font"> 分离线程 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74810" class="d-block text-truncate right-font"> 代码知识积累 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74809" class="d-block text-truncate right-font"> python知识整理 </a> </h4> </li> <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2"> <h4 class="h6 my-0"> <a href="/topic/74808" class="d-block text-truncate right-font"> 函数参数 </a> </h4> </li> </ul> </div> </div> </div> </div> <footer class="text-muted small bg-dark py-4 mt-3" id="footer"> <div class="container"> <div class="row"> <div class="col"> Powered by Hwhale <!-- 其他信息请追加此处 --> </div> </div> </div> </footer> <!--[if ltg IE 9]> <script>window.location = '/browser';</script> <![endif]--> <script src="/lang/zh-cn/lang.js?13"></script> <script src="/view/js/jquery.min.js?13"></script> <script src="/view/js/popper.min.js?13"></script> <script src="/view/js/bootstrap.min.js?13"></script> <script src="/view/js/copyxn.js?13"></script> <script src="/view/js/bootstrap-plugin.js?13"></script> <script src="/view/js/async.min.js?13"></script> <script src="/view/js/form.js?13"></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?346221f3ab3bcc7f46ef28d352ee78b9"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script> var host = window.location.host; if (host =="www.hwhale.com"){ (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> <script> var debug = DEBUG = 0; var url_rewrite_on = 3; var url_path = '/'; var fid = 16; var uid = 0; var gid = 0; xn.options.water_image_url = '/view/img/water-small.png'; /*水印图片 / watermark image*/ </script> <script src="/view/js/hwhale.js?13"></script> <!--图片赖加载需要的自己删掉注释 <script src="/view/js/echo.min.js?13"></script> <script> (function ($) { path = "/"; $("body img").each(function(k, v){var img = $("img").get(k).outerHTML;img = img.replace('src', 'data-echo');$(this).replaceWith(img);}); })(jQuery); echo.init({offset: 100,throttle: 250,unload: false}); </script> --> <!-- Scroll to Top Button--> <a class="scroll-to-top rounded" href="javascript:void(0);"> <i class="icon-angle-up"></i> </a> <!-- Scroll to bottom Button--> <a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"> <i class="icon-angle-down"></i> </a> </body> </html> <link href="/view/css/vs2015.css" rel="stylesheet"> <script src="/view/js/highlight.pack.js"></script> <script src="/view/js/highlightjs-badge.min.js"></script> <script> // $("code").wrapInner(document.createElement("pre")); if( $("[allenmark_388]").attr('allenmark_388')>0){ $("#ref_question").html(' 网友还发现一个类似的问题请参阅:https://stackoverflow.com/questions/'+$("[allenmark_388]").attr('allenmark_388')+'/'); } var originalElements = document.querySelectorAll('span[fhref]'); originalElements.forEach(function(originalElement) { var originalInnerText = originalElement.innerText; var originalHref = originalElement.getAttribute('fhref'); var newElement = document.createElement('span'); var newText = document.createTextNode(originalInnerText + ' ' + originalHref); newElement.appendChild(newText); originalElement.parentNode.replaceChild(newElement, originalElement); }); setTimeout(function () { var pres = document.querySelectorAll("pre>code"); for (var i = 0; i < pres.length; i++) { hljs.highlightBlock(pres[i]); } var options = { contentSelector: ".message", // Delay in ms used for `setTimeout` before badging is applied // Use if you need to time highlighting and badge application // since the badges need to be applied afterwards. // 0 - direct execution (ie. you handle timing loadDelay:0, // CSS class(es) used to render the copy icon. copyIconClass: "icon-copy", // CSS class(es) used to render the done icon. checkIconClass: "icon-heart", // hook to allow modifying the text before it's pasted onBeforeTextCopied: function(text, codeElement) { return text; // you can fix up the text here } }; window.highlightJsBadge(options); },10); </script> <style> p pre{ display: inline!important; } li pre{ display: inline!important; } "@media print { .code-badge { display: none; } } .code-badge-pre { position: relative; } .code-badge { display: flex; flex-direction: row; white-space: normal; background: transparent; background: #333; color: white; font-size: 0.8em; opacity: 0.5; border-radius: 0 0 0 7px; padding: 5px 8px 5px 8px; position: absolute; right: 0; top: 0; } .code-badge.active { opacity: 0.8; } .code-badge:hover { opacity: .95; } .code-badge a, .code-badge a:hover { text-decoration: none; } .code-badge-language { margin-right: 10px; font-weight: 600; color: goldenrod; display: none; } .code-badge-copy-icon { font-size: 1.2em; cursor: pointer; padding: 0 7px; margin-top:2; } .fa.text-success:{ color: limegreen !important} </style> <script> var forum_url = '/list/16'; var safe_token = 'mwUxvO4uYlB_2BhlWt0XdI9cH3yifOXf2bnR6AYMA9_2FKCEMAa_2F8MvKF63xexh0rSs9v9_2FFIXU7jZoFDQ9YPehU_2FQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); /*缩放图片,适应屏幕大小*/ function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); /* 815 : 746; 734 746*/ jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } /*var percent = xn.min(100, xn.ceil((img_width / jmessage_width) * 100));*/ if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { /*window.open(jimg.attr('src'));*/ }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } /*对于超宽的表格,加上响应式*/ function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); /*输入框自动伸缩*/ var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-16"]').addClass('active'); </script>