loadHTML($html);
$xp = new DOMXPath($dom);
$nodeList = $xp->query($path);
foreach($nodeList as $domElement){
return $domElement->nodeValue;
}
}
function __outputCSV(&$vals, $key, $filehandler) {
fputcsv($filehandler, $vals, ';', '"');
}
function getUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after Ns
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
$res = curl_exec( $ch );
$info = curl_getinfo($ch);
$pattern = "#META http-equiv=['|\"]Refresh['|\"] content=['|\"][0-9]+;url=(.*?)['|\"]#si";
if(preg_match($pattern, $res, $loc)) {
$url = $loc[1];
}else{
$url = $info['url'];
}
/*if(stristr($theRes, 'XML-RPC server accepts POST requests only.'))*/ return array($res, $info, $url);
}
if(isset($_POST['txt'])){
$tab = preg_split('#(\n)#',$_POST['txt']);
$results = array(array('url','status','redirect','title','h1','robots','keywords','description','charset'));
foreach($tab as $u){
$u = trim($u);
if($u != ''){
$proc = getUrl($u);
//print_r($proc[1]);
$html = $proc[0];
$seo = array();
$seo['url'] = $u;
$seo['status'] = $proc[1]['http_code'];
if($u != $proc[2]) $seo['redirect'] = $proc[2];
else $seo['redirect'] = '';
$seo['title'] = getDomValue('//title', $html);
$seo['h1'] = getDomValue('//h1', $html);
$seo['robots'] = getDomValue('//meta[@name="robots"]/@content', $html);
$seo['keywords'] = getDomValue('//meta[@name="keywords"]/@content', $html);
$seo['description'] = getDomValue('//meta[@name="description"]/@content', $html);
$ch = getDomValue('//meta[contains(@content,"charset")]/@content', $html);//gere le bon encodage
$ch = split('charset=', $ch);
$ch = $ch[1];
$seo['charset'] = $ch;
$results[] = $seo;
}
}
/*echo '';
print_r($results);
echo '
';*/
//header("Content-Type: text/csv");
$fp = fopen('seoextractor.csv', 'w');
array_walk($results, '__outputCSV', $fp);
fclose($fp);
echo 'Resultat en CSV';
}
?>
SEO EXTRACTOR
Collez votre liste d'url dans le champ texte ci-dessous et cliquez sur Go