I have this code sample (written by someone else) that parses the website, and finds the latest version’s URL of each type of file (beta/developmental/release) and returns them.
I would like to be able to do something like bukkit.php?version=beta and have it automatically go to that URL and start the download. How would I go about doing something of that nature?
<?php
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/>";
}
}
}
}
?>
Rather use a regular expression to find the url