Reputation:
I have written a small tool for our customers that downloads the latest stable version of this software for our customers from a permanent link provided by the developers. However, their beta and developmental versions do have permanent links, thus requiring me to manually update the code everytime.
Would there be any easy method of parsing this site http://dl.bukkit.org/downloads/craftbukkit/ to obtain the link to the most recent download URL of each type? (Release/Beta/Developmental)?
Upvotes: 0
Views: 321
Reputation: 3428
require_once('simple_html_dom.php');
$html = file_get_html('http://dl.bukkit.org/downloads/craftbukkit/');
$dom = new DOMDocument;
libxml_use_internal_errors(true);
echo $dom->loadHTML($html) ? "success<br/>" : "failed<br/>";
libxml_clear_errors();
$dom->preserveWhiteSpace = true;
foreach ($dom->getElementsByTagName('div') as $element){
if($element->getAttribute('class') == "innerContent"){
foreach ($element->getElementsByTagName('a') as $link) {
if( $link->getAttribute('class') == "tooltipd")
{
echo $link->getAttribute('href')."<br/>";
}
}
}
}
Upvotes: 1
Reputation: 2912
Just take a look at this PHP Lib: http://simplehtmldom.sourceforge.net/ It does exactly what you're looking for.
Upvotes: 1