Jon*_*yon 86 directory web-crawler
是否可以在任何给定的网站上找到所有页面和链接?我想输入一个URL并生成该站点所有链接的目录树?
我看过HTTrack,但下载了整个网站,我只需要目录树.
Han*_*Gay 66
检查linkchecker -it将抓取网站(在服从时robots.txt)并生成报告.从那里,您可以编写用于创建目录树的解决方案.
Ele*_*Bit 37
如果您的浏览器中有开发人员控制台(JavaScript),则可以在以下位置键入以下代码:
urls = document.querySelectorAll('a'); for (url in urls) console.log(urls[url].href);
Run Code Online (Sandbox Code Playgroud)
缩短:
n=$$('a');for(u in n)console.log(n[u].href)
Run Code Online (Sandbox Code Playgroud)
另一种选择可能是
Array.from(document.querySelectorAll("a")).map(x => x.href)
Run Code Online (Sandbox Code Playgroud)
有了你$$(它就更短了
Array.from($$("a")).map(x => x.href)
Run Code Online (Sandbox Code Playgroud)
或者甚至更短
Array.from 不需要地图
Array.from($$("a"), (x) => x.href)
Run Code Online (Sandbox Code Playgroud)
或者
[...$$("a")].map((x) => x.href)
Run Code Online (Sandbox Code Playgroud)
或者
$x('//a[@href!="#"]').map(({ href }) => href)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
386722 次 |
| 最近记录: |