PDA

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


rainboww
14.03.2010, 02:23
Помогите спарсить капчу гугла.

У меня вот такой код, странно должен работать но что-то не работает
<?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%3F d%3D%252Fcreate-blog.g%26a%3DADD_SERVICE_FLAG&hl=ru&sendvemail=true&followup=https%3A%2F%2Fwww.blogger.com%2Floginz%3F d%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

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

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

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
$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пасиб