Php ile Bot Yapımı Part 1

php ile bot yapımının 1. videosu

Kaynak Dosyaları:

index.php

[syntax type=”php”]

<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<title></title>
</head>
<body>
<?php
include ‘bot.php’;

Bot(“http://www.sosyalradar.com”);
?>
</body>
</html>

[/syntax]

bot.php

[syntax type=”php”]

<?php

function Bot($url) {

$ac = Curl($url);
preg_match_all(‘/<h2 class=”uk-article-title uk-margin-small-top uk-h2″ itemprop=”headline”>(.*?)<\/h2>/’, $ac, $link);

foreach ($link[1] as $ln) {

preg_match(‘/<a href=”(.*?)” title=”(.*?)” rel=”bookmark”>(.*?)<\/a>/’, $ln, $alan);
echo $alan[1] . “<br>”;
}
}

function Curl($url, $proxy = NULL) {
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_HEADER => false,
CURLOPT_ENCODING => “”,
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
);

$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
curl_close($ch);
$header[‘errno’] = $err;
$header[‘errmsg’] = $errmsg;
$header[‘content’] = $content;
return str_replace(array(“\n”, “\r”, “\t”), NULL, $header[‘content’]);
}

[/syntax]

 

kaynak dosyaları: http://goo.gl/aEASas

Bir Cevap Yazın