[php]
$url = “http://www.lottomaticaitalia.it/lotto/home/”;
$input = @file_get_contents($url) or die(‘Could not access file: $url’);
$regexp = “]*href=(\”??)([^\” >]*?)\1[^>]*>(.*)< \/a>”;
$regexp = ”
]*>.*
(.*)< \/div>.*
(.*)< \/div>”;
if(preg_match_all(“/$regexp/siU”, $input, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
# $match[2] = link address
# $match[3] = link text
$tbl = preg_replace (‘(class=\”.*\”)’,” , $match[2]);
echo $match[1];
echo $tbl;
}
}
$last_upd = get_option(‘lotto_lastdate’);
if ($last_upd != $match[1]) {
update_option(‘lotto_lastdate’, $match[1]);
$testo = “I numeri dell’estrazione del lotto:\n”;
$testo = $testo.$tbl.”\nEcco i 20 numeri vincenti del 10 e lotto\n”.$match[3];
$my_post = array();
$my_post[‘post_title’] = ‘Estrazioni del lotto di ‘.$match[1];
$my_post[‘post_content’] = $testo;
$my_post[‘post_status’] = ‘publish’;
$my_post[‘post_author’] = 1;
$my_post[‘post_category’] = array(9);
wp_insert_post( $my_post );
}
[/php]