Your IP : 216.73.216.39


Current Path : /home/wirbesti/unwaehlbar.ch/test/
Upload File :
Current File : /home/wirbesti/unwaehlbar.ch/test/bkinitiativen-de.php

<?php

$url = "https://www.bk.admin.ch/ch/f/pore/vi/vis_1_3_1_1.html";
$ch1= curl_init();
curl_setopt ($ch1, CURLOPT_URL, $url );
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1,CURLOPT_VERBOSE,1);
curl_setopt($ch1, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
curl_setopt ($ch1, CURLOPT_REFERER,'http://www.google.com');  //just a fake referer
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1,CURLOPT_POST,0);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 20);

$htmlContent= curl_exec($ch1);

$re = '/.*a\shref="vis(?<key>.*)\.html.*>\'(?<slogan>.*)\'<\/a>/m';

preg_match_all($re, $htmlContent, $matches, PREG_SET_ORDER, 0);

// Print the entire match result
// var_dump($matches);

foreach ($matches as $key) {
    # code...
    echo $key['key'].' '.$key['slogan'].'<br/>';
}

?>