【问题标题】:Test all internal links测试所有内部链接
【发布时间】:2021-07-08 12:44:04
【问题描述】:

我运行一个 NodeJS 服务器。我有时会删除页面而忘记删除参考。我想测试所有内部链接是否正常工作。我想象一个爬虫和一个 npm 测试包,可以建立一个从主页链接的所有内部页面的列表,并确认它们返回 200 状态代码。

实现这一目标的最佳框架是什么?

【问题讨论】:

    标签: node.js testing web-crawler


    【解决方案1】:

    无需重新发明轮子。

    我已经为此目的使用了hyperlink NPM 包。

    【讨论】:

    • 我浏览了软件包页面,我认为我需要首先将我的网站(可能带有损坏的链接)部署到公共 URL,然后在其上运行 hyperlink 爬虫。是对的吗?是否有其他软件包在部署之前在本地执行?
    • 您可以在本地使用hyperlink 进行操作。只需将其指向您的本地文件,并将 --canonicalroot 设置为真正的公共 URL。
    • 啊,例如http://localhost:3000/。知道了谢谢!你能推荐另一个包吗?不幸的是,hyperlink 引入了 11 个未通过npm audit fix --force 修复的高严重性问题:deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
    • 别担心。许多高严重性问题实际上并没有那么严重,而且您也没有在浏览器上下文中使用 core-js。
    猜你喜欢
    • 2015-12-31
    • 2011-05-17
    • 2016-04-19
    • 2021-03-20
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    • 2016-03-05
    相关资源
    最近更新 更多