A voir également:
- Parser Fopen
- Fopen() ✓ - Forum C
- Fopen ✓ - Forum PHP
- Msxml 4.0 sp3 parser - Forum Logiciels
- Probleme fopen (C) ✓ - Forum Programmation
- Html parser python - Forum HTML
4 réponses
je n'arrive pas à utiliser ce code..
<?php
$file = "http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576";
$contenu = fread(fopen($file, "r"), filesize($file));
preg_match_all("|<title>(.*)</title>|U", $contenu, $titre);
/* le \d signifie n'importe quelle décimale */
/* le .* signifie n'importe quel caractère '.' présent de 0 à n fois '*' */
?>
<?php
$file = "http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576";
$contenu = fread(fopen($file, "r"), filesize($file));
preg_match_all("|<title>(.*)</title>|U", $contenu, $titre);
/* le \d signifie n'importe quelle décimale */
/* le .* signifie n'importe quel caractère '.' présent de 0 à n fois '*' */
?>
ca non plus ca marche pas:
<?php
$page_title = "n/a";
$meta_descr = "n/a";
$meta_keywd = "n/a";
if ($handle = @fopen("http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576", "r")) {
$content = "";
while (!feof($handle)) {
$part = fread($handle, 1024);
$content .= $part;
if (eregi("</head>", $part)) break;
}
fclose($handle);
$lines = preg_split("/\r?\n|\r/", $content); // turn the content in rows
$is_title = false;
$is_descr = false;
$is_keywd = false;
$close_tag = ($xhtml) ? " />" : ">"; // new in ver. 1.01
foreach ($lines as $val) {
if (eregi("<title>(.*)</title>", $val, $title)) {
$page_title = $title[1];
$is_title = true;
}
if (eregi("<meta name=\"description\" content=\"(.*)\"([[:space:]]?/)?>", $val, $descr)) {
$meta_descr = $descr[1];
$is_descr = true;
}
if (eregi("<meta name=\"keywords\" content=\"(.*)\"([[:space:]]?/)?>", $val, $keywd)) {
$meta_keywd = $keywd[1];
$is_keywd = true;
}
if ($is_title && $is_descr && $is_keywd) break;
}
}
echo "$page_title<br>";
echo "$meta_descr<br>";
echo "$meta_keywd<br>";
?>
<?php
$page_title = "n/a";
$meta_descr = "n/a";
$meta_keywd = "n/a";
if ($handle = @fopen("http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576", "r")) {
$content = "";
while (!feof($handle)) {
$part = fread($handle, 1024);
$content .= $part;
if (eregi("</head>", $part)) break;
}
fclose($handle);
$lines = preg_split("/\r?\n|\r/", $content); // turn the content in rows
$is_title = false;
$is_descr = false;
$is_keywd = false;
$close_tag = ($xhtml) ? " />" : ">"; // new in ver. 1.01
foreach ($lines as $val) {
if (eregi("<title>(.*)</title>", $val, $title)) {
$page_title = $title[1];
$is_title = true;
}
if (eregi("<meta name=\"description\" content=\"(.*)\"([[:space:]]?/)?>", $val, $descr)) {
$meta_descr = $descr[1];
$is_descr = true;
}
if (eregi("<meta name=\"keywords\" content=\"(.*)\"([[:space:]]?/)?>", $val, $keywd)) {
$meta_keywd = $keywd[1];
$is_keywd = true;
}
if ($is_title && $is_descr && $is_keywd) break;
}
}
echo "$page_title<br>";
echo "$meta_descr<br>";
echo "$meta_keywd<br>";
?>
ca non plus :
quelqu'un peux m'aider !!
<?php
$title = "n/a";
if ($fp = @fopen('http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576', 'r' )) {
$cont = "";
// read the contents
while( !feof( $fp ) ) {
$buf = trim(fgets( $fp, 4096 )) ;
$cont .= $buf;
}
// get tag contents
@preg_match( "<title>(.*)</title>", $cont, $match );
// tag contents
$title = strip_tags(@$match[1]);
}
echo $match[1];
echo $title;
?>
quelqu'un peux m'aider !!
c'est bon j'ai trouvé ! merci de ne PAS m'avoir aidé :)
<?php
$page = "http://www.avocatparis.org/Eannuaire/Resultat2.aspx?cnbf=66576";
// tags
$start = '<title>';
$end = '<\/title>';
// open the file
$fp = fopen( $page, 'r' );
$cont = "";
// read the contents
while( !feof( $fp ) ) {
$buf = trim( fgets( $fp, 4096 ) );
$cont .= $buf;
}
// get tag contents
preg_match( "/$start(.*)$end/s", $cont, $match );
// tag contents
$contents = $match[ 1 ];
echo $contents;
?>