【问题标题】:Count the number of links on Webpage?计算网页上的链接数?
【发布时间】:2015-06-28 12:55:30
【问题描述】:

如何计算网页上存在的链接数量,如果页面包含社交链接,则不应计算 google 、 linkdin 、 facebook 、 twitter 页面。

【问题讨论】:

  • 你可以根据<a href=... >标签来统计链接... :)
  • 可以统计页面上锚标签的数量。

标签: php html dom


【解决方案1】:

这会告诉你所有的a 标签,除了 facebook 链接。自己添加其余部分:P

<script>
    $("a[href^='https://www.facebook.com']").remove();

    console.log(    document.body.getElementsByTagName('a').length)
</script>

【讨论】:

    猜你喜欢
    • 2019-11-22
    • 2019-01-08
    • 2021-03-10
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 2012-03-30
    相关资源
    最近更新 更多