Banco do Brasil, segunda Viua de boleto: não consegue enviar POST para https://www63.bb.com.br/portalbb/boleto/boletos/hc21e,802,3322,10343.bbx

Asked

Viewed 204 times

0

I need to implement web query to the second route of BB billets, from the page https://www63.bb.com.br/portalbb/boleto/boletos/hc21e,802,3322,10343.bbx.

I must send the CNPJ and the document number, it returns the captcha, that the user needs to type, so send all the data by the form.

But I can’t even read the page https://www63.bb.com.br/portalbb/boleto/boletos/hc21e,802,3322,10343.bbx, the answer I have is:

This Document you requested has Moved temporarily.

It’s now at https://www63.bb.com.br/portalbb/boleto/error.bbx;jsessionid=Hw8iawojligfnl1-_5UHxnF3Ompa5vosJ0VvswNxLfjP4GK2ySuN! -536097846?Cid=580485

And with each access, it generates a different session ID and code. When I try to access this page, it gives the same error.

I’m accessing with Curl, someone has some light?

1 answer

2

This probably indicates that there was a 302 HTTP redirect:

This Document you requested has Moved temporarily.

How did I respond in:

Must use the CURLOPT_FOLLOWLOCATION, example:

$urlPost = '<site>';
$post_fields = array(
  .... //items do formulário
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlPost);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);

curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); //passa o user-agent atual para o curl

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);

Of course this will not solve all the problems, especially if they use an anti-bot, or an anti-CSRF, which there is no practical solution to circumvent.

  • William, exactly this !!!! It worked perfectly and solved my problem !!! :-)

  • @Lucianacorreia otimo, please take advantage and mark the answer as correct, if you do not know how to do read this: https://pt.meta.stackoverflow.com/q/1078/3635 - I am grateful!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.