【问题标题】:Is there a way to get all file links from a single URL?有没有办法从单个 URL 获取所有文件链接?
【发布时间】:2020-12-26 03:38:38
【问题描述】:

假设我有example.com/a.png 这是一个文件,example.com 是主要网站。总的来说,example.com 只是一个托管原始图像文件的站点。如果我不知道某些文件的名称,例如 b.png,其 URL 可能是 example.com/b.pngexample.com/b/b.png,我将如何找到它?主页是空白的,托管在Apache 2.4.38 server

现在,我正在通过生成一个随机数并在其上附加.png 来进行盲测。它看起来像:

https.get(`https://example.com/${randomNumber}.png`, {"User-Agent":"..."}, r => {
//...
})

【问题讨论】:

    标签: javascript apache https


    【解决方案1】:

    尝试使用正则表达式。它可能看起来像这样:

    const regExp = /^https:\/\/example.com\/(.+).png$/;
    
    // Matches
    console.log(regExp.test('https://example.com/b.png'));
    
    // Matches
    console.log(regExp.test('https://example.com/b/b.png'));
    
    // Doesn't match because of different extension
    console.log(regExp.test('https://example.com/b/b.jpg'));
    
    /*
    Usage:
    https.get(/^https:\/\/example.com\/(.+).png$/, {"User-Agent":"..."}, r => {
      //...
    })
    */

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-29
      • 1970-01-01
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多