[JS]获得Apache目录列表的文件名 [英] [JS]Get file names of Apache Directory Listing

查看:223
本文介绍了[JS]获得Apache目录列表的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一个Apache2的Direotry清单中的所有文件创建Ajax-TP请求他们每个人。但我不能找到一个正则表达式的匹配。


解决方案

  $ DIR ='http://www.example.com/directory';$数据=新的DOMDocument();
@ $&DATA- GT; loadHTMLFile($目录);
$链接=阵列();
的foreach($数据 - >的getElementsByTagName('A')为$链接)
{
    $ URL = $链路>的getAttribute(href属性);
    如果($网址[0] =='?')//跳过栏链接
    {
        $链接[] = $网址;
    }
}
的print_r($链接);

I am trying to get all the files of an Apache2 Direotry Listing to create AJAX-Requests tp each of them. But I can't find a RegExp to match in .

解决方案

$dir = 'http://www.example.com/directory';

$data = new DOMDocument();
@$data->loadHTMLFile($dir);
$links = array();
foreach($data->getElementsByTagName('a') as $link)
{
    $url = $link->getAttribute('href');
    if ($url[0] !== '?') // skip column links
    {
        $links[] = $url;
    }
}
print_r($links);

这篇关于[JS]获得Apache目录列表的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆