купил 50 прокси по первой ссылке PHP: function file_get_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array("Referer: [url=HTTP://Yandex.Ru]HTTP://Yandex.Ru[/url]", "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_PROXY, "'".$proxy[array_rand($proxy = file("proxy.db"))]."'"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $str = curl_exec($ch); curl_close($ch); return $str; } print $content = file_get_content("http://yandex.ru/yandsearch?text=ноутбук"); в $content пусто в чем проблема?
Couldn't resolve proxy ''121.14.158.75' и так по всем прокси хреновые прокси? посоветуйте, где купить робочие прокси! какие имено прокси нужны (анонимные, соксы) ?
руки из жопы и не понимание процесса Код (Text): hosting(root):/usr/www/www.php.ru/template#>telnet 121.14.158.75 80 Trying 121.14.158.75... Connected to 121.14.158.75. Escape character is '^]'. GET / HTTP/1.0 host: ya.ru HTTP/1.0 200 OK Server: nginx Date: Tue, 23 Feb 2010 03:50:24 GMT Content-Type: text/html; charset=utf-8 Content-Length: 4962 Last-Modified: Tue, 12 Jan 2010 15:29:06 GMT Accept-Ranges: bytes Age: 131872 X-Cache: HIT from gameimg.baofeng.com Via: 1.0 gameimg.baofeng.com:80 (squid/2.6.STABLE22) Connection: close <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><meta http-equiv=Content-Type content="text/html;charset=utf-8"><title>Яндекс</title><link rel="shortcut icon"href="http://img.yandex.net/i/favicon.ico"><base target="_top"> [...] Connection closed by foreign host.
ну так что не так в PHP: function file_get_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array("Referer: [url=HTTP://Yandex.Ru]HTTP://Yandex.Ru[/url]", "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_PROXY, "'".$proxy[array_rand($proxy = file("proxy.db"))]."'"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $str = curl_exec($ch); curl_close($ch); return $str; } print $content = file_get_content("http://yandex.ru/yandsearch?text=ноутбук"); ?
PHP: <?php function my_file_get_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array("Referer: [url=HTTP://Yandex.Ru]HTTP://Yandex.Ru[/url]", "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_PROXY, '121.14.158.75:80'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $str = curl_exec($ch); if(curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); exit(); } curl_close($ch); return $str; } print $content = my_file_get_content("http://yandex.ru/yandsearch?text=440hz"); ?> Код (Text): tornado(root):/home/440hz/test#>php proxy.php <!DOCTYPE html> <html id="nojs"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/> <title> 440hz — [...]
проблему по коду решил! осталась проблема по списку прокси его покупал, но из 50 только 3-4 не забанены яндексом где взять (купить) нормальные прокси. Посоветуйте!