简体   繁体   English

Firefox HTML检查器:如何复制单个HTML标签?

[英]Firefox HTML inspector: how to copy single HTML tag?

I have a website and need to transport a form to another website. 我有一个网站,需要将表格传输到另一个网站。 I however only need certain tags not the whole form block with all it's tables and divs. 但是,我只需要某些标签,而不需要整个表格和div的整个表单块。

When selecting a html-tag in inspector, I can copy inner HTML, outer HTML or CSS styles but how can I just copy that very exact tag I selected without it's child nodes, just the selected line in HTML code? 在检查器中选择html-tag时,我可以复制内部HTML,外部HTML或CSS样式,但是如何才能复制我选择的非常精确的标记而没有子节点,而仅复制HTML代码中的所选行?

I ask this because the HTML is minified and I can't just select and copy a tag in source. 我之所以这样问,是因为HTML已缩小 ,我不能只选择并复制源代码中的标记。 Same when I chose "copy outer HTML" I get the whole HTML subtree minified, means everything in one line. 选择“复制外部HTML”时,同样如此,整个HTML子树都缩小了,意味着所有内容都在一行中。

How can I quickly search and copy certain tags from the three without grabbing everything in the branch? 如何快速搜索和复制三个标签中的某些标签,而又不获取分支中的所有内容?

Edit: People, thanks for all your suggestions but please note that I wrote about a MINIFIED HTML page I have here. 编辑:人们,谢谢您的所有建议,但请注意,我写的是关于此处的MINIFIED HTML页面。

Just open Debugger near Inspector 只需在Inspector附近打开Debugger

Then find page file... then copy with any select range as you want 然后找到页面文件...然后根据需要复制任意选择范围

在此处输入图片说明

UPDATE if it minify click here UPDATE如果缩小请点击这里 在此处输入图片说明

If I understood what you want try this 如果我了解您想要的内容,请尝试此

在此处输入图片说明

Since your question seems unsolved yet, let me come up with a creative approach I use for similar tasks from time to time: 由于您的问题似乎尚未解决,因此让我想出一种创造性的方法,不时地用于类似的任务:

(1) Creative solution: Page manipulation (1)创造性的解决方案:页面操纵

If you don't have a javascript framework of your choice (eg jQuery) on that page, add it using a browser-extension that adds it when page has loaded. 如果您在该页面上没有选择的javascript框架(例如jQuery),请使用浏览器扩展来添加它,并在页面加载时添加它。

Then you write a bit of javascript code that removes unwanted child elements of the desired parents in a loop or so. 然后,编写一些javascript代码,以循环方式删除所需父对象的不需要的子元素。 That sounds like lots of work but since you asked this question I assume you need dozens if not hundreds of elements so it might be worth taking the time to write such loop(s). 这听起来很麻烦,但是由于您提出了这个问题,所以我假设您需要数十个(即使不是数百个)元素,因此花时间编写这样的循环可能是值得的。

When the code you injected processed the page and removed everything you don't want, you can then copy the code like mentioned by others here. 当您注入的代码处理了页面并删除了所有不需要的内容后,您就可以像其他人在这里提到的那样复制代码。


(2) Alternative solution: Beautify the code beforhand (2)替代解决方案:先美化代码

If the given solution(s) don't work for you, one could try to beautify the code by copying the source to a webpage that auto-indends html/js code. 如果给定的解决方案不适合您,则可以尝试通过将源代码复制到自动添加html / js代码的网页来美化代码。 You could then optionally save it into a html-file and approach that one again like mentioned here before. 然后,您可以选择将其保存到html文件中,然后再次处理,就像前面提到的那样。


Sidenote 边注

If either this idea is too much work or you need this frequently you are probably approaching this on the wrong side. 如果这个想法太费力,或者您经常需要这个想法,那么您可能是错误的做法。 When working on frontend (only) you are always limited to what you have. 在前端上工作时(仅限),您总是受限于所拥有的东西。 If you could approach from the backend you could then build from the data/information whatever you need. 如果您可以从后端访问,则可以根据需要使用数据/信息进行构建。 If you could provide a bit more information about why you need this and how much code you are talking about one could maybe come up with a more sustainable solution! 如果您可以提供更多有关为什么需要此信息以及正在谈论的代码数量的信息,那么可能会提出一种更可持续的解决方案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM