<?php
function getir($baslangic, $son, $cekilmek_istenen)
{
@preg_match_all('/' . preg_quote($baslangic, '/') .
'(.*?)'. preg_quote($son, '/').'/i', $cekilmek_istenen, $m);
return @$m[1];
}
$url = "https://www.alexa.com/siteinfo/foreverautohits.com";
$icerik = file_get_contents($url);
$alexa = getir('<strong class="metrics-data align-vmiddle"><!-- Alexa web traffic metrics are available via our API at http://aws.amazon.com/awis -->','</strong>',$icerik);
echo "<b>Alexa Sırası :</b> " . $alexa[0] . "<br />";
?>
sorun ne olabilir ?
farklı siteden veri çekmek çalışmayan kod
3
●264
- 28-02-2019, 15:35:21Böylede olabilir, sadece global sırasını getiriyor.
$url = "https://www.alexa.com/siteinfo/foreverautohits.com"; $re = '/"global":(.*?)}/m'; $str = file_get_contents($url); preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); echo '<pre>'; print_r($matches); echo '</pre>'; echo "<b>Alexa Sırası :</b> " . $matches[0][1] . "<br />"; - 28-02-2019, 15:38:04<?php
function veri($url)
{
$ch = curl_init();
$timeout = 60;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_REFERER, "https://www.alexa.com");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function getir($desen,$kaynak)
{
preg_match_all($desen,$kaynak,$cikti);
return $cikti;
}
$veri = veri("https://www.alexa.com/siteinfo/foreverautohits.com");
$alexa = getir('@<strong class="metrics-data align-vmiddle">(.*?)</strong>@si',$veri);
echo "<b>Alexa Sırası :</b> " . strip_tags($alexa[0][0]) . "<br />";
?> - 28-02-2019, 15:41:36çalıştı, teşekkürler.senyeterkiiste adlı üyeden alıntı: mesajı görüntüle
buda çalıştı, teşekkürler....Scorpion2763 adlı üyeden alıntı: mesajı görüntüle