Skrypt do sprawdzania pozycji w google.pl
Krótki, prosty skrypt do sprawdzania pozycji w google:
Tagi: google, pozycjonowanie stron, skrypty, wypociny<?php
function pozycja ($sQ, $sSite) {
$sLinkRegExp = ‘/<li class=g><h3 class=r><a href="([^"]+)" class=l>/’;
$sURLTpl = ‘http://www.google.pl/search?hl=pl&q=%s&num=100′;$rC = curl_init();
curl_setopt($rC, CURLOPT_HEADER, 0);
curl_setopt($rC, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rC, CURLOPT_VERBOSE, 1);
curl_setopt($rC, CURLOPT_REFERER, ‘www.google.pl’);
curl_setopt($rC, CURLOPT_URL, sprintf($sURLTpl, urlencode($sQ)));
$sData = curl_exec($rC);
curl_close($rC);preg_match_all($sLinkRegExp, $sData, $aResults);
$aResults = array_pop($aResults);$iPosition = ‘-’;
foreach($aResults as $iKey => $sRow) {
if(strpos(strip_tags($sRow), ‘http://’ . $sSite) !== false) {
$iPosition = $iKey + 1;
}
}printf("<td>Pozycja strony: <b>%d</b></td>", $iPosition);
echo "<td>Fraza: <b>";
echo $_GET['fraza'];
echo "</b></td><td>Adres: <b>";
echo $_GET['adres'];
echo "</b></td><td>";
$link = "http://www.google.pl/search?hl=pl&q=". urlencode($sQ);
echo "<a target=\"_blank\" href=";
echo $link;
echo ">";
echo $sQ;
echo "</a></td>";
}
?>
<?php
if (!isset($_GET['submit'])) {
?>
<table>
<form method="get" action="<?php echo $PHP_SELF;?>">
<tr><td><b>adres</b></td><td><input type="text" size="36" maxlength="36" name="adres"><br /></td></tr>
<tr><td><b>fraza</b></td><td><input type="text" size="36" maxlength="36" name="fraza"><br /></td></tr>
<tr><td></td><td><input type="submit" value="znajdz" name="submit"><br /></td></tr></table>
<?php
} else {
$fraza = $_GET['fraza'];
$adres = $_GET['adres'];
echo "<table CELLSPACING=\"15\" border=\"1\" rules=\"col\" width=\"100%\">
<tr>";
pozycja ($fraza, $adres);
echo "</tr>
</table>";}
?>
Reader Comments:
Be the first to leave a comment!