Als nächstes möchte ich an dieser Stelle den vom AMR generierten URL String wissen oder mir irgendwie zusammenbauen.
Als drittes muss ich an dieser Stelle noch abfragen, ob der Artikel online ist.
Hintergrund ist, dass ich hier beim Speichern des jeweiligen Artikels, das Ganze als statische Datei in einem Cache Verzeichnise speichern möchte. Den Code dazu hab ich schon. Das Ganze funktioniert mit der Snoopy Klasse. Leider geht das Ganze derzeit nur mit Artikeltext und nicht mit Bildern. Aber reicht mir schon.
Code: Alles auswählen
<?php
include "Snoopy.class.php";
$url="http://www.domain.de/directory/index.html";
fetch($url);
/*
* Function to fetch a webpage in the given subdirectory
* @param string $url
*/
function fetch($url){
$snoopy = new Snoopy;
$url2= parse_url($url, PHP_URL_PATH);
$pathTrimmed = trim($url2, '/');
$mkdirpath = substr($pathTrimmed, 0, -11);
if($snoopy->fetch($url))
{
if(!dir_exists($mkdirpath))
{
mkdir($mkdirpath,0777,TRUE);
}
$fh = fopen($pathTrimmed, 'w') or die("can't open file");
fwrite($fh, $snoopy->results);
fclose($fh);
}
else
{
echo "error fetching document: ".$snoopy->error."\n";
}
}
/*
* Function to check recursively if dirname is exists in directory's tree
* @param string $dir_name
* @param string [$path]
* @return bool
*/
function dir_exists($dir_name = false, $path = './') {
if(!$dir_name) return false;
if(is_dir($path.$dir_name)) return true;
$tree = glob($path.'*', GLOB_ONLYDIR);
if($tree && count($tree)>0) {
foreach($tree as $dir)
if(dir_exists($dir_name, $dir.'/'))
return true;
}
return false;
}
?>