我正在开发工具来检查所有类型资源的状态,例如 js、css、img 等以及给定网站的其他 url。
例如给定网址:www.abc.com 然后我需要检查所有类型的资源和 www.abc.com 的 url 的状态
为此,我正在使用 jquery ajax...因此,我将获得该 url (abc.com) 的 html 内容
但问题是如何从该 html 内容中找到所有 url?我尝试了很多方法,但无法弄清楚我是如何得到的。
请为此提供一些好的解决方案。
提前致谢。
最佳答案
尝试使用 .each()
来迭代 img
, link
, script
元素;检索 src
或 href
属性值
$("img, link, script").each(function() {
// do stuff with `this.src` or `this.href`
console.log(this.src || this.href)
})
关于javascript - 从文档文本(内容)中检索所有 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34735157/