08.29Автоматический addurl в yandex
Написал скрипт автоматического addurl в yandex.
good.txt - файл с удачным addurl
bad.txt - файл с не удачным addurl
urls.txt - файл с урл
proxy.txt - файл с прокси,если потребуется работа через прокси
Удобно ставить на крон,можно указать задержку между добавлением ссылок.
Скачать
< ?php /** * @author RushteR * @copyright 2009 */ set_time_limit(0); include ("func.php"); $good = fopen("good.txt", "at"); // good file $bad = fopen("bad.txt", "at"); // bad file //$proxy = file("proxy.txt"); // uncomment if you need a proxy $urls = file("urls.txt"); // url file $ackey = ""; // ac-service.info key $patch = 'C://wamp/www/yaddr\\'; // full path to the folder (if windows) $sleep = 0; // delay time function savecap($url, $name = "savecap", $type = "jpg", $cook = "") { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (isset($proxy)) curl_setopt($ch, CURLOPT_PROXY, $proxy[rand(0, count($proxy) - 1)]); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_COOKIE, $cook); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.7)'); $result = curl_exec($ch); $fp = fopen($name . "." . $type, 'w'); fwrite($fp, $result); fclose($fp); } $ch = curl_init(); foreach ($urls as $url) { curl_setopt($ch, CURLOPT_URL, 'http://webmaster.yandex.ru/addurl.xml'); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (isset($proxy)) curl_setopt($ch, CURLOPT_PROXY, $proxy[rand(0, count($proxy) - 1)]); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.7)'); $resp = curl_exec($ch); preg_match('#name="key" type="hidden" value="(.*?)">#', $resp, $out); preg_match_all('#^Set-Cookie: ([^;]*)#mi', $resp, $cookies); $cook = implode('; ', $cookies[1]); savecap("http://captcha.yandex.net/image?key=$out[1]", "savecap", "jpg", $cook); $code = recognize($patch . "savecap.jpg", $ackey, 0); curl_setopt($ch, CURLOPT_URL, "http://webmaster.yandex.ru/addurl.xml"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (isset($proxy)) curl_setopt($ch, CURLOPT_PROXY, $proxy[rand(0, count($proxy) - 1)]); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_COOKIE, $cook); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.7)'); curl_setopt($ch, CURLOPT_POSTFIELDS, "url=$url&key=$out[1]&rep=$code&do=add"); $responce = curl_exec($ch); if (strstr($responce, "302")) { echo $url . " OK<br />"; fwrite($good, "$url - Ok\n"); flush(); ob_flush(); } else { echo $url . " BAD<br />"; fwrite($bad, "$url - BAD\n"); flush(); ob_flush(); } unset($urls[0]); file_put_contents("urls.txt", $urls); sleep($sleep); } ?>
func.php
< ?php function recognize($filename, $apikey, $is_verbose = true, $rtimeout = 5, $mtimeout = 120, $is_phrase = 0, $is_regsense = 0, $is_numeric = 0, $min_len = 0, $max_len = 0) { if (!file_exists($filename)) { if ($is_verbose) echo "file $filename not found\n"; return false; } $postdata = array('method' => 'post', 'key' => $apikey, 'file' => '@' . $filename, //полный путь к файлу 'phrase' => $is_phrase, 'regsense' => $is_regsense, 'numeric' => $is_numeric, 'min_len' => $min_len, 'max_len' => $max_len, ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://ac-service.info/in.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $result = curl_exec($ch); if (curl_errno($ch)) { if ($is_verbose) echo "CURL returned error: " . curl_error($ch) . "\n"; return false; } curl_close($ch); if (strpos($result, "ERROR") !== false) { if ($is_verbose) echo "server returned error: $result\n"; return false; } else { $ex = explode("|", $result); $captcha_id = $ex[1]; if ($is_verbose) echo "captcha sent, got captcha ID $captcha_id\n"; $waittime = 0; if ($is_verbose) echo "waiting for $rtimeout seconds\n"; sleep($rtimeout); while (true) { $result = file_get_contents('http://ac-service.info/res.php?key=' . $apikey . '&action=get&id=' . $captcha_id); if (strpos($result, 'ERROR') !== false) { if ($is_verbose) echo "server returned error: $result\n"; return false; } if ($result == "CAPCHA_NOT_READY") { if ($is_verbose) echo "captcha is not ready yet\n"; $waittime += $rtimeout; if ($waittime > $mtimeout) { if ($is_verbose) echo "timelimit ($mtimeout) hit\n"; break; } if ($is_verbose) echo "waiting for $rtimeout seconds\n"; sleep($rtimeout); } else { $ex = explode('|', $result); if (trim($ex[0]) == 'OK') return trim($ex[1]); } } return false; } } ?>
-
http://ozon-peak.ru xalturkin
-
http://klipner.ru rushter
-
Kaja
-
http://klipner.ru rushter
-
Kaja
-
Kaja
-
Kaja
-
http://klipner.ru rushter
-
qq
-
qq
-
qq
-
http://klipner.ru rushter
-
qq
-
http://klipner.ru rushter
-
qq
-
http://klipner.ru rushter
-
qq
-
http://klipner.ru rushter
-
qq
-
qq
-
http://klipner.ru rushter
-
qq
-
http://klipner.ru rushter
-
qq
-
qq
-
qq
-
qq
-
hiemoRoumejes
-
123
-
123
-
http://klipner.ru rushter
-
123
-
mongolor
-
Анна
-
http://buzzman.ru Никита Buzzman
-
http://klipner.ru rushter