PDA

Просмотр полной версии : curl +htts


Krist_ALL
26.09.2009, 22:05
народ, совсемне знаю курла.)))
напишите плз скрипт который конектица по хттпс и полуычает содержимое содердиомое страницы.

Deathdreams
26.09.2009, 22:20
порт 443 поставь для подключения.

Pashkela
26.09.2009, 22:21
<?php
set_time_limit(0);
$url = "https://hashcracking.info/index.php?4";
$ref = "https://hashcracking.info/index.php";
$ua = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.4) Gecko/2008102920 AdCentriaIM/1.7 Firefox/3.0.4";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cook");
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cook");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$res = curl_exec($ch);
preg_match_all('#[0-9a-f]{32}#i', $res, $matches);
print_r($matches);
?>

b3
27.09.2009, 03:12
порт 443 поставь для подключения.
порт ненада, добавь строку:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
этого хватит с головой, вот пример авторизации на яндекс:

function login($login,$pass)
{

$ch = curl_init('https://passport.yandex.ru/passport?mode=auth');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3');
curl_setopt($ch, CURLOPT_REFERER, 'https://passport.yandex.ru/passport?mode=auth');
curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'cook.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'cook.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "login=$login&passwd=$pass");
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$res = curl_exec($ch);
if(preg_match('#https:\/\/passport\.yandex.ru\/passport\?mode=logout#',$res))
return true;
}