[JS]Get file names of Apache Directory Listing [cl

2019-09-21 06:20发布

问题:

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 .

回答1:

$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);