Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. $user_agent_array = file('proxy.txt');
  2.  
  3. $reffer_array = array(
  4. 'http://yandex.ru',
  5. 'http://google.com'
  6. );
  7.  
  8. $proxy_array = file('proxy.txt');
  9.  
  10. function arrayRand($array) {
  11. return $array[mt_rand(0, count($array))];
  12. }
  13.  
  14. function getContent($url) {
  15. GLOBAL $user_agent_array;
  16. GLOBAL $reffer_array;
  17. GLOBAL $proxy_array;
  18. $user_agent = trim(arrayRand($user_agent_array));
  19. $reffer = arrayRand($reffer_array);
  20. $proxy = trim(arrayRand($proxy_array));
  21.  
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL, $url);
  24. curl_setopt($ch, CURLOPT_REFERER, $reffer);
  25. curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt'); //сохранить куки в файл
  26. curl_setopt ($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt'); //считать куки из файла
  27. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7); //тайм-аут соединения
  28. curl_setopt($ch, CURLOPT_TIMEOUT, 7);
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); //возврат необработанного ответа
  30. curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  31. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  32. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //переходить по редиректам
  33. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);// не проверять SSL сертификат
  34. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// не проверять Host SSL сертификата
  35. $content = curl_exec($ch);
  36. }
  37.  
  38. echo getContent('http://gadarutym.ru/3/good.php');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement