Good night, I need to return data from a specific site for my application, for this I chose to use the cURL () PHP method, it sends a post and I return the information I want, the problem is that in that return comes the complete page of the form I accessed, I did not find any way to just get input data from this form. I need to capture the information returned from the form and move to json.
Here is the method that performs this search:
public function busca(Request $request){
$data = $request->all();
$cURL = curl_init('http://www.site.com.br/resultado.php');
curl_setopt($cURL, CURLOPT_HEADER, false);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
$dados = array(
'num_cnpj' => $data['cnpj'],
'botao' => 'Consultar'
);
curl_setopt($cURL, CURLOPT_POST, true);
curl_setopt($cURL, CURLOPT_POSTFIELDS, $dados);
curl_setopt($cURL, CURLOPT_REFERER, 'http://www.site.com.br/index.php');
$resultado = curl_exec($cURL);
curl_close($cURL);
return $resultado;
}