查找 HTML 中图像的链接(包括常见标签/属性之外的链接)
我想找到(使用 javascript)HTML 页面上对图像链接的所有引用。由于我也在寻找可能不会显示或处于未知属性类型的图像引用,因此仅查找图像标签或 src 等是不够的。因此,我还没有找到使用 html 解析器来执行此操作的简单方法。
浏览完 stackoverflow 的帖子后,我不想因为使用不敢说出它的名字的黑暗匹配方法而失去我的灵魂 - 我犹豫是否在这里提及它,以免我引来那些讨厌使用 regu1@ 的人的愤怒r_expre$$i0n$ 就是为了这样的目的。但我也还没有找到正确的方法。
我知道所有看起来像图像链接的链接都不是,反之亦然,但这没关系。我不需要完全覆盖,只需要尽可能广泛的覆盖而不牺牲速度。所以我猜想跟踪所有链接太密集了,将自己限制在“看起来”像图像的链接就可以了。
I'd like to find (using javascript) all of the references to image links on an HTML page. Since I'm also looking for image references that may not be displayed, or are in unknown attribute types, simply looking for image tags or src's etc. isn't enough. As such, I haven't yet found a simple method using an html parser to do this.
Having looked through the stackoverflow threads, I don't want to lose my soul by employing the dark method of matching that dare not speak its name - I hesitate to mention it here, lest I draw down the fury of those who hate using regu1@r_expre$$i0n$ for such a purpose. But I haven't found the right method yet either.
I know that all links that look like images links are not, and vice versa, but that's OK. I don't need complete coverage, just the widest possible without sacrificing speed. so I'm guessing that following all the links is too intensive, and restricting myself to links that 'look' like images will be just fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
安东尼是对的,正则表达式对于我的目的来说效果很好。
Anthony was right, regex worked just fine for my purpose here.