napoler / ganon

Automatically exported from code.google.com/p/ganon
0 stars 0 forks source link

cURL and ganon #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have to use cURL because the website has an air protected. 

How should I initialize the object if I already have the HTML code?

<code>

$username = 'user';
$password = 'password';

$loginUrl1 = 'url1';
$loginUrl2 = 'url2';

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($curl, CURLOPT_HEADER, 0); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_TIMEOUT, 60); 
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; 
Windows NT 5.0)"); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile"); 
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile"); # SAME cookiefile 
curl_setopt($curl, CURLOPT_URL, $loginUrl1); # this is where you first time 
connect - GET method authorization in my case, if you have POST - need to edit 
code a bit 
$url1= curl_exec($curl); 
curl_setopt($curl, CURLOPT_URL, $loginUrl2); # this is where you are requesting 
POST-method form results (working with secure connection using cookies after 
auth) 
curl_setopt($curl, CURLOPT_POSTFIELDS, 
"frmUsername=".$username."&frmPassword=".$password); # form params 
$domprotected= curl_exec($curl);    

$html = file_get_dom('$domprotected'); //Don't WORK

</code>

Original issue reported on code.google.com by motux...@gmail.com on 18 Jan 2014 at 5:26

GoogleCodeExporter commented 9 years ago
$html = str_get_dom($domprotected); //Should WORK

Original comment by bartek12...@gmail.com on 3 Feb 2014 at 11:50