• <i id='PYsjw'><tr id='PYsjw'><dt id='PYsjw'><q id='PYsjw'><span id='PYsjw'><b id='PYsjw'><form id='PYsjw'><ins id='PYsjw'></ins><ul id='PYsjw'></ul><sub id='PYsjw'></sub></form><legend id='PYsjw'></legend><bdo id='PYsjw'><pre id='PYsjw'><center id='PYsjw'></center></pre></bdo></b><th id='PYsjw'></th></span></q></dt></tr></i><div id='PYsjw'><tfoot id='PYsjw'></tfoot><dl id='PYsjw'><fieldset id='PYsjw'></fieldset></dl></div>

    <small id='PYsjw'></small><noframes id='PYsjw'>

        <bdo id='PYsjw'></bdo><ul id='PYsjw'></ul>
      <tfoot id='PYsjw'></tfoot>
      <legend id='PYsjw'><style id='PYsjw'><dir id='PYsjw'><q id='PYsjw'></q></dir></style></legend>

        如何从 .html 页面中提取链接和标题?

        时间:2023-07-15
          <tbody id='SvLwg'></tbody>

        <tfoot id='SvLwg'></tfoot>
        <legend id='SvLwg'><style id='SvLwg'><dir id='SvLwg'><q id='SvLwg'></q></dir></style></legend>

          • <bdo id='SvLwg'></bdo><ul id='SvLwg'></ul>
            <i id='SvLwg'><tr id='SvLwg'><dt id='SvLwg'><q id='SvLwg'><span id='SvLwg'><b id='SvLwg'><form id='SvLwg'><ins id='SvLwg'></ins><ul id='SvLwg'></ul><sub id='SvLwg'></sub></form><legend id='SvLwg'></legend><bdo id='SvLwg'><pre id='SvLwg'><center id='SvLwg'></center></pre></bdo></b><th id='SvLwg'></th></span></q></dt></tr></i><div id='SvLwg'><tfoot id='SvLwg'></tfoot><dl id='SvLwg'><fieldset id='SvLwg'></fieldset></dl></div>

                1. <small id='SvLwg'></small><noframes id='SvLwg'>

                2. 本文介绍了如何从 .html 页面中提取链接和标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  对于我的网站,我想添加一个新功能.

                  for my website, i'd like to add a new functionality.

                  我希望用户能够上传他的书签备份文件(如果可能,从任何浏览器),这样我就可以将其上传到他们的个人资料中,而他们不必手动插入所有这些...

                  I would like user to be able to upload his bookmarks backup file (from any browser if possible) so I can upload it to their profile and they don't have to insert all of them manually...

                  我唯一缺少的部分是从上传的文件中提取标题和 URL 的部分.. 任何人都可以提供线索从哪里开始或从哪里阅读?

                  the only part i'm missing to do this it's the part of extracting title and URL from the uploaded file.. can anyone give a clue where to start or where to read?

                  使用的搜索选项和(如何从原始 HTML 文件?)这是与我最相关的问题,它没有谈论它..

                  used search option and (How to extract data from a raw HTML file?) this is the most related question for mine and it doesn't talk about it..

                  我真的不介意它是使用 jquery 还是 php

                  I really don't mind if its using jquery or php

                  非常感谢.

                  推荐答案

                  谢谢大家,我明白了!

                  最终代码:

                  $html = file_get_contents('bookmarks.html');
                  //Create a new DOM document
                  $dom = new DOMDocument;
                  
                  //Parse the HTML. The @ is used to suppress any parsing errors
                  //that will be thrown if the $html string isn't valid XHTML.
                  @$dom->loadHTML($html);
                  
                  //Get all links. You could also use any other tag name here,
                  //like 'img' or 'table', to extract other tags.
                  $links = $dom->getElementsByTagName('a');
                  
                  //Iterate over the extracted links and display their URLs
                  foreach ($links as $link){
                      //Extract and show the "href" attribute.
                      echo $link->nodeValue;
                      echo $link->getAttribute('href'), '<br>';
                  }
                  

                  这会显示为.html 文件中的所有链接分配的 文本和href.

                  This shows you the anchor text assigned and the href for all links in a .html file.

                  再次感谢.

                  这篇关于如何从 .html 页面中提取链接和标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 PHP 中将纯文本 URL 转换为 HTML 超链接 下一篇:没有 &lt;a&gt; 的正则表达式匹配链接标签

                  相关文章

                  • <bdo id='7btGo'></bdo><ul id='7btGo'></ul>

                  <small id='7btGo'></small><noframes id='7btGo'>

                  <tfoot id='7btGo'></tfoot>
                3. <legend id='7btGo'><style id='7btGo'><dir id='7btGo'><q id='7btGo'></q></dir></style></legend>

                    1. <i id='7btGo'><tr id='7btGo'><dt id='7btGo'><q id='7btGo'><span id='7btGo'><b id='7btGo'><form id='7btGo'><ins id='7btGo'></ins><ul id='7btGo'></ul><sub id='7btGo'></sub></form><legend id='7btGo'></legend><bdo id='7btGo'><pre id='7btGo'><center id='7btGo'></center></pre></bdo></b><th id='7btGo'></th></span></q></dt></tr></i><div id='7btGo'><tfoot id='7btGo'></tfoot><dl id='7btGo'><fieldset id='7btGo'></fieldset></dl></div>