Alexa scriptimizin kodlarını sizlerle paylaşıyorum.3 dosyadır ayrı ayrı kaydedip topluca atıyorsunuz.
functions.php
index.php
style.css
Sadece deep-kod.org a özeldir.
functions.php
PHP Kod:
<?php
set_time_limit(86400);
function curlAlexa($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.google.com.tr/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$chData = curl_exec($ch);
curl_close($ch);
return $chData;
}
function buffer($str){
return str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $str);
}
function getAlexa($site){
$page = curlAlexa('https://www.alexa.com/siteinfo/'.$site);
## GLOBAL
$pageExp = explode("src='/images/icons/globe-sm.jpg'", $page);
$pageExq = explode('</strong>', $pageExp[1]);
$globalExp = explode('-->', buffer($pageExq[0]));
$data['global'] = trim($globalExp[1]);
## COUNTRY
$pageExp = explode("<img class='img-inline ' src='/images/fla", $page);
$pageExq = explode('</strong>', $pageExp[1]);
$country = buffer($pageExq[0]);
preg_match_all("#gs/(.*?).png' title='(.*?) Flag' alt='(.*?) Flag'>#", $country, $cikti);
$data['flag'] = trim($cikti[1][0]);
$data['country'] = trim($cikti[2][0]);
$countryExp = explode('vmiddle">', $country);
$data['countryRank'] = trim($countryExp[1]);
return $data;
}
?>
index.php
PHP Kod:
<?php include 'functions.php' ?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8" />
<title>Çalışma</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form action="" method="POST">
<div class="kapsa">
<h2>Alexa Bot</h2>
<label class="frmEleman">
<em>Siteler</em>
<textarea name="iSites" placeholder="Siteleri buraya alt alta yazınız."></textarea>
</label>
<div class="buttonEleman">
<button type="submit">GÖNDER</button>
</div>
</div>
</form>
<?php
if ( isset($_POST['iSites']) ){
$siteler = explode(chr(10), $_POST['iSites']);
?>
<div class="sonuclar">
<h2>Sonuçlar (<?php echo count($siteler) ?> Site)</h2>
<div class="sonuclarListe">
<?php foreach ($siteler as $site){ $siteData = getAlexa(trim($site)) ?>
<div class="sonucTek">
<div class="siteAdi"><?php echo trim($site) ?></div>
<div class="rank">
<em><img src="https://www.alexa.com/images/icons/globe-sm.jpg" />Global Rank</em>
<b><?php echo $siteData['global'] ?></b>
</div>
<div class="rank">
<em><img src="https://www.alexa.com/images/flags/<?php echo $siteData['flag'] ?>.png" />Rank in <?php echo $siteData['country'] ?></em>
<b><?php echo $siteData['countryRank'] ?></b>
</div>
</div>
<?php flush(); ob_get_contents(); ob_flush(); } ?>
</div>
</div>
<?php
}
?>
</body>
</html>
style.css
PHP Kod:
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&subset=latin,latin-ext');
*{padding:0;margin:0;border:0}
body{margin:0px;background:#f7f7f7}
ul, li, p, h1, h2, h3, h4{list-style:none;padding:0;margin:0}
input, select, textarea, button{outline:none;border:none}
.kapsa, .sonuclar{background:#fff;padding:20px;width:900px;margin:20px auto;overflow:hidden;box-shadow:0px 1px 5px rgba(0,0,0, 0.1)}
.kapsa h2, .sonuclar h2{font:normal 500 19px 'Roboto';color:#403c84}
.sonuclar{margin-top:0px}
.frmEleman{margin-top:20px;position:relative;display:block;cursor:pointer}
.frmEleman em{font:normal 400 14px 'Roboto';color:#999;display:block;margin-bottom:6px}
.frmEleman textarea{width:100%;background:#fafafa;padding:10px;border:2px solid #e5e5e5;border-radius:4px;font:normal 500 14px/24px 'Roboto';color:#5b5b5b;transition:all 0.14s ease-in-out;box-sizing:border-box;min-height:240px;max-width:100%;min-width:100%}
.frmEleman textarea::placeholder{color:#ae8c8c}
.frmEleman textarea:focus{background:#fff;border-color:#a7d7f9;box-shadow:0px 0px 24px -2px rgba(167,215,249, 0.8)}
.buttonEleman button{display:inline-block;width:210px;border-radius:4px;background:#f54d0b;color:#fff;font:normal 500 14px 'Roboto';cursor:pointer;padding:13px 0px 12px 0px;transition:background 0.14s ease-in-out;margin-top:20px}
.buttonEleman button:hover{background:#ffab1e}
/**/
.sonuclarListe{display:flex;flex-wrap:wrap}
.sonucTek{background:#f9f9f9;border:1px solid #ddd;border-radius:4px;margin-top:20px;margin-left:20px;padding:12px;width:calc((100% - 40px - 78px) / 3)}
.sonucTek:nth-child(3n + 1){margin-left:0px}
.siteAdi{font:normal 500 17px 'Roboto';color:#27ae60}
.rank{margin-top:14px}
.rank em{display:flex;font:normal 400 13px 'Roboto';color:#888;align-items:center}
.rank em img{margin-right:8px}
.rank b{font:normal 700 21px 'Roboto';color:#333;display:block;margin-top:6px}
Sadece deep-kod.org a özeldir.