Test Downloading Groups:

preserveWhiteSpace = false; //@$dom->loadHTMLFile($address); libxml_use_internal_errors(true); $dom->loadHTML($content); return $dom; } function parse_group($name, $address) { echo '
  • '.$name.':'; $dom = get_dom($address); $domxpath = new DOMXPath($dom); $filtered = $domxpath->query('//div[@class="caption"]'); $postal = $filtered[$filtered->length-1]->getElementsByTagName('p')->item(0)->nodeValue; $postal_all = trim(preg_replace('/\s+/', ' ', $postal)); $postal_short = substr($postal_all, 0, strpos($postal_all, ",")); echo $postal.'
    '.$postal_all.'
    '.$postal_short.'
  • '; return array("name" =>$name, "address" => $postal_all); } function parse_country($address){ $groups = array(); $dom = get_dom($address); $domxpath = new DOMXPath($dom); $filtered = $domxpath->query('//div[@class="country-index"]'); $links = $filtered[0]->getElementsByTagName('a'); echo ''; return $groups; } //phpinfo(); $address = "http://improwiki.com/de/liste_improgruppen_aus/deutschland/de"; //echo 'Trying to load '.$address.' ...
    '; /*$html = file_get_contents($address); //echo '

    Got File!

    '; //echo '
    '.$html.'
    '; //$dom = new DOMDocument(); $content = utf8_decode ( $html ); // $dom = new DOMDocument('1.0', 'utf-8'); $dom->preserveWhiteSpace = false; //@$dom->loadHTMLFile($address); $dom->loadHTML($content); echo '

    Got DOM!

    '; //$div = $dom->getElementsByTagName('body'); //$content = $div->saveHTML(); $domxpath = new DOMXPath($dom); $newDom = new DOMDocument; $newDom->formatOutput = true; //$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']"); $filtered = $domxpath->query('//div[@class="country-index"]'); $links = $filtered[0]->getElementsByTagName('a'); for ($i=0; $i<$links->length; $i++) { echo '
    '.$links->item($i)->nodeValue.' : '.$links->item($i)->attributes->getNamedItem('href')->nodeValue.'
    '; }*/ $spider = false; if($spider){ //$allgroups = array(); $allgroups = parse_country($address); //array_push($allgroups, $groups); print_r(json_encode($allgroups)); file_put_contents("groups.json", json_encode($allgroups)); } $groupdb = file_get_contents("groups.json"); echo ''; ?>
    0/0