Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Skrypt sprawdzający czy strona otrzymała ban od google
VishOne
post
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 6.08.2010

Ostrzeżenie: (0%)
-----


Witam, potrzebuję napisać skrypt, który będzie sprawdzał czy strona otrzymała ban od google i problem polega na tym, że nie wiem za bardzo jak on powinien działać. Mógłby mnie ktoś naprowadzić jak to wykonać lub jeżeli takowy spotkał to podać link do artykułu / gotowego skryptu, abym mógł to wykorzystać?

Z góry dzięki za pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kiler129
post
Post #2





Grupa: Zarejestrowani
Postów: 566
Pomógł: 35
Dołączył: 21.06.2006

Ostrzeżenie: (0%)
-----


Załączam Ci moją klasę do cURL`a:

  1. <?php
  2. class cURL {
  3. public $userAgents = array(
  4. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)",
  5. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)",
  6. "Opera/9.63 (Windows NT 6.0; U; ru) Presto/2.1.1",
  7. "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5",
  8. "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.18) Gecko/20081203 Firefox/2.0.0.18",
  9. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16",
  10. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1",
  11. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)",
  12. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
  13. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
  14. "AmigaVoyager/3.4.4 (MorphOS/PPC native)",
  15. "xChaos_Arachne/5.1.89;GPL,386+",
  16. "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2 (Change: 0 )",
  17. "Mozilla/6.0; (Spoofed by Amiga-AWeb/3.5.07 beta)",
  18. "Mozilla/4.61 [en] (X11; U; ) - BrowseX (2.0.0 Windows)",
  19. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14)",
  20. "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5b) Gecko/20030917 Camino/0.7+",
  21. "Mozilla/4.08 (Charon; Inferno)",
  22. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10",
  23. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Comodo_Dragon/4.0.1.6 Chrome/4.0.249.78 Safari/532.5",
  24. "Contiki/1.0 (Commodore 64; <a href="http://dunkels.com/adam/contiki/)&quot;" target="_blank">http://dunkels.com/adam/contiki/)"</a>,
  25. "Democracy/0.8.1 (http://www.participatoryculture.org)",
  26. "edbrowse/2.2.10",
  27. "ELinks/0.12~pre2.dfsg0-1ubuntu1-lite (textmode; Debian; Linux 2.6.32-4-jolicloud i686; 143x37-2)",
  28. "Emacs-W3/4.0pre.46 URL/p4.0pre.46 (i686-pc-linux; X11)",
  29. "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.5) Gecko/20060731 Epiphany/2.14 Firefox/1.5.0.5");
  30.  
  31. public $proxies = array("http;localhost;8118"); //Format are type;ip;port, type can be only socks5 for now
  32. public $proxy = array(); //Chosed proxy addess, default there is no proxy
  33. public $ua = "Mozilla/5.0 (compatible; SimpleCURL/1.0 en-US)";
  34. private $returnTransfer = true;
  35. private $returnHeaders = false;
  36. private $connTimeout = 10;
  37. private $locationFollow = true; //Follow Location: CURLOPT_FOLLOWLOCATION
  38. private $locationLimit = 10; //Prevent recursive redirection
  39. private $keepSession = true; //keep session cookie or not
  40. private $freshConn = false; //Always use fresh connection
  41.  
  42.  
  43. function shuffleUA($save=true) {
  44. $newUA = $this->userAgents[rand(0, (count($this->userAgents)-1))];
  45. if(empty($newUA)) return false; //Maybe array is empty?
  46. if($save) $this->ua = $newUA;
  47. return $newUA;
  48. }
  49.  
  50. function shuffleProxy($save=true) {
  51. $proxy = $this->proxies[rand(0, (count($this->proxies)-1))];
  52. $proxy = explode(";", $proxy);
  53. if(empty($proxy) || count($proxy) != 3) return false; //Maybe array is empty or proxy is invalid
  54. $prx["type"] = $proxy[0]; //Proxy type
  55. $prx["ip"] = $proxy[1]; //Proxy ip
  56. $prx["port"] = $proxy[2]; //Proxy port
  57.  
  58. if($save) $this->proxy = $prx;
  59. return $prx;
  60. }
  61.  
  62. private function initCURL($url, $ref, $method="get", $cookies=array(), $postFields=array(), $headers=array()) {
  63. $ch = curl_init();
  64. curl_setopt($ch, CURLOPT_URL, $url);
  65. curl_setopt($ch, CURLOPT_RETURNTRANSFER, $this->returnTransfer); //Return document instead echo
  66. curl_setopt($ch, CURLOPT_HEADER, $this->returnHeaders); //Return headers
  67. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connTimeout); //Connection timeout
  68. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->locationFollow); //Follow Location: headers
  69. curl_setopt($ch, CURLOPT_MAXREDIRS, $this->locationLimit); //Following Location: limit
  70. curl_setopt($ch, CURLOPT_COOKIESESSION, $this->keepSession); //Keep sessions cookies
  71. curl_setopt($ch, CURLOPT_FRESH_CONNECT, $this->freshConn); //Always use fresh connection instead of keep-alive
  72. curl_setopt($ch, CURLOPT_USERAGENT, $this->ua); //Set useragent
  73. if(!empty($ref)) curl_setopt($ch, CURLOPT_REFERER, $ref); //Set referer
  74. if(!empty($headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //Extra custom headers
  75.  
  76. if(!empty($this->proxy)) {
  77. curl_setopt($ch, CURLOPT_PROXYTYPE, (($this->proxy["type"]=="socks5")?CURLPROXY_SOCKS5:CURLPROXY_HTTP));
  78. curl_setopt($ch, CURLOPT_PROXY, $this->proxy["ip"].":".$this->proxy["port"]);
  79. }
  80.  
  81. if(!empty($cookies)) {
  82. $cURLcook = ""; //Prevent E_NOTICE
  83. foreach($cookies as $key=>$val) $cURLcook .= urlencode($key)."=".urlencode($val).";";
  84. curl_setopt($ch, CURLOPT_COOKIE, substr($cURLcook, 0, -1)); //Do not forgot to cur last ;
  85. }
  86.  
  87. if($method=="post") {
  88. curl_setopt($ch, CURLOPT_POST, true);
  89. if(!empty($postFields)) {
  90. $cURLpf = ""; //Prevent E_NOTICE
  91. foreach($postFields as $key=>$val) $cURLpf .= urlencode($key)."=".urlencode($val)."&";
  92. curl_setopt($ch, CURLOPT_POSTFIELDS, substr($cURLpf, 0, -1)); //Do not forgot to cur last &
  93. }
  94. }
  95.  
  96.  
  97. return $ch;
  98. }
  99.  
  100. function getData($url, $ref, $method="get", $post=array()) {
  101. $ch = $this->initCURL($url, $ref, $method, array(), $post);
  102. $buffer = curl_exec($ch);
  103. //var_dump(curl_error($ch));
  104. curl_close($ch);
  105. return $buffer;
  106. }
  107. }
  108. ?>


Aby jej tworzysz jej obiekt, ustawiasz co potrzeba (domyślnie nie musisz nic), wywołujesz metodę getData() z odpowiednimi parametrami.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.10.2025 - 01:29