Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   вытащить капчу гугла (https://forum.antichat.xyz/showthread.php?t=186672)

rainboww 14.03.2010 02:23

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

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

<?php
$ch 
curl_init();  
    
curl_setopt($chCURLOPT_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($chCURLOPT_RETURNTRANSFER1);  
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);  
    
curl_setopt($chCURLOPT_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($curlCURLOPT_URL$url); 
  
curl_setopt($curlCURLOPT_USERAGENT'User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)'); 
  
curl_setopt($curlCURLOPT_COOKIEFILE'C:/cookies.txt');
  
curl_setopt($curlCURLOPT_HEADER,1); 
  
curl_setopt($curlCURLOPT_ENCODING'gzip,deflate'); 
  
curl_setopt($curlCURLOPT_AUTOREFERERtrue);     
  
curl_setopt($curlCURLOPT_RETURNTRANSFER1); 
  
curl_setopt($curlCURLOPT_TIMEOUT20); 
  
curl_setopt ($curlCURLOPT_SSL_VERIFYPEER0);
  
curl_setopt ($curlCURLOPT_SSL_VERIFYHOST0);
  
$html curl_exec($curl); // execute the curl command 
  
curl_close($curl); // close the connection 
?>


rainboww 15.03.2010 11:53

Cпасиб


Время: 16:28