1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
</head>
<body>
<?php
$recherche = $_GET['recherche_texte'];
//Initation des variables
$rechercher = " ";
$remplacer = "+";
$expression = str_replace($rechercher, $remplacer, $recherche);
$url_google = "http://news.google.fr/news?hl=fr&ned=fr&q=$expression&ie=UTF-8&output=rss";
$fp = @fopen($url_google,"r");
while(!feof($fp)) $raw .= @fgets($fp, 4096);
fclose($fp);
if( eregi("<item>(.*)</item>", $raw, $rawitems ) ) {
$items = explode("<item>", $rawitems[0]);
echo "<ul>";
for( $i = 0; $i < count($items)-1; $i++ ) {
eregi("<title>(.*)</title>",$items[$i+1], $title );
eregi("<link>(.*)</link>",$items[$i+1], $url );
eregi("<categorie>(.*)</categorie>",$items[$i+1], $cat);
$titre = html_entity_decode(utf8_decode(str_replace("\", "\'", $title[1])));
$autd = strrpos($titre, "-");
$source = substr($titre, $autd+2);
$titre = substr($titre, '0', $autd);
echo "<li><a href='".$url[1]."'>".$titre."</a> (".$source.")";
}
echo "</ul>";
}
?>
</body>
</html> |
Partager