ANTICHAT

ANTICHAT (https://forum.antichat.io/index.php)
-   PHP (https://forum.antichat.io/forumdisplay.php?f=37)
-   -   вытащить капчу гугла (https://forum.antichat.io/showthread.php?t=186672)

rainboww 14.03.2010 02:23

вытащить капчу гугла
 
Помогите спарсить капчу гугла.

У меня вот такой код, странно должен работать но что-то не работает
PHP код:

<?php
$ch 
= curl_init();  
    
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/accounts/NewAccount?service=blogger&continue=https%3A%2F%2Fwww.blogger.com%2Floginz%3Fd%3D%252Fcreate-blog.g%26a%3DADD_SERVICE_FLAG&hl=ru&sendvemail=true&followup=https%3A%2F%2Fwww.blogger.com%2Floginz%3Fd%3D%252Fhome%26a%3DSERVICE_ONLY&naui=8"); 
    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
    
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
    
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
    
$result = curl_exec($ch);
       
preg_match('#<input type="hidden" id="newaccounttoken" name="newaccounttoken" value="([a-f0-9]+)">#i', $result, $key);
              
       
print_r($key[1]);
       
$result = curl_exec($ch);  
       
curl_close ($ch); 

?>


IgrikX 14.03.2010 03:10

Ну, так ты попробуй пройти на страницу.. пишет не существует..

rainboww 14.03.2010 10:33

заменил на https://www.google.com/accounts/NewAccount?service=blogger

Все равно не пахало. Там дело в регулярке было.. не та регулярка

Вот если кому надо, рабочая:

PHP код:

preg_match('#<input type="hidden" id="newaccounttoken" name="newaccounttoken" value="(.*?)">#i', $result, $key); 


IgrikX 14.03.2010 13:32

там ssl

IgrikX 14.03.2010 13:58

Вот так вот страница загружается и теперь ты можешь парсить данные..
PHP код:

<?php 
$url
="https://www.google.com/accounts/NewAccount?continue=http%3A%2F%2Fwww.google.ru%2F&hl=ru"; 
  
$curl = curl_init();     
  
curl_setopt($curl, CURLOPT_URL, $url); 
  
curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)'); 
  
curl_setopt($curl, CURLOPT_COOKIEFILE, 'C:/cookies.txt');
  
curl_setopt($curl, CURLOPT_HEADER,1); 
  
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); 
  
curl_setopt($curl, CURLOPT_AUTOREFERER, true);     
  
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
  
curl_setopt($curl, CURLOPT_TIMEOUT, 20); 
  
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
  
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
  
$html = curl_exec($curl); // execute the curl command 
  
curl_close($curl); // close the connection 
?>


rainboww 15.03.2010 11:53

Cпасиб


Время: 19:29