Edit the page rescued with curl before executing it with curl_exec

0

Ok guys I explain I am connecting with curl to my bank page, it enters perfectly, but when I run the page as it does on my local server, the hyperlinks look for them on my local server something like this href="/ HB / frontEnd / css / styleInterno.css ", and as they obviously are not running it, and therefore the JS functions that I need to work to allow me to download the account statement or make a transfer using a .js script do not work for me, the idea that I have in mind is to edit those addresses by the complete addresses something like this link "for this to work, I wanted to put the answer $ ch in file ($ ch) to read it line by line and do a str_Replace but it did not work if someone has an idea how to do this and could help me, here I put them my code

<?php //curl coneccion al banco

function loginBanfanb(){  

$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) 
Gecko/20030624 Netscape/7.1 (ax)"; 
$cookies = getcwd() . "/cookies.txt";

$ch = curl_init("https://banfanbenlinea.banfanb.com.ve/HB/AppServN.EBK");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);  
curl_setopt ($ch, CURLOPT_REFERER, 
"https://banfanbenlinea.banfanb.com.ve/HB/frontEnd/loginNatural.jsp");
curl_setopt ($ch, CURLOPT_POSTFIELDS,"inciar_tpo=&intento=1&vacio=vacio&tempUserid=******&userid=60385496465674&passw dnew=******&passwdHidden=%123456789");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
//curl_setopt($ch, CURLOPT_HEADER, true);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_exec($ch);

curl_close($ch);
}

loginBanfanb();

?>
    
asked by Jesus Contreras 11.06.2018 в 02:09
source

1 answer

0

guys I already found the way to do what I was looking for and I put the code but on entering it generates an error that does not allow me to get the final result I do not know if it can be done better with more curl calls here the code

<?php //curl coneccion al banco
function loginBanfanb(){  

$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) 
Gecko/20030624 Netscape/7.1 (ax)"; 
$cookies = getcwd() . "/cookies.txt";

$ch = curl_init("https://banfanbenlinea.banfanb.com.ve/HB/AppServN.EBK");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);  
curl_setopt ($ch, CURLOPT_REFERER, 
"https://banfanbenlinea.banfanb.com.ve/HB/frontEnd/loginNatural.jsp");
curl_setopt ($ch, CURLOPT_POSTFIELDS,"inciar_tpo=&intento=1&vacio=vacio&tempUserid=******&userid=602154185481&passwdnew=******&passwdHidden=5145151");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//curl_exec($ch);

$result = curl_exec($ch);
if ($result !== false) { //funciono ?
 //echo "Descarga correcta.";
 $result = str_replace('/HB', 
"https://banfanbenlinea.banfanb.com.ve/HB",$result);
 //file_put_contents("lista.m3u", $result);
 echo $result;
}

curl_close($ch);
}

loginBanfanb();

?>
    
answered by 11.06.2018 в 02:38