Web Scraping c/ CURL retorna valores diferentes
Pessoal, tudo bem? Estou tentando fazer um web scraping com CURL, mas o resultado é diferente do que eu vejo no browser (Chrome).
O site retorna preços de alugueis de carro. Quando eu abro via browser, ele já mostra automaticamente os valores em reais. Por algum motivo, quando eu faço o request via CURL ele mostra os valores em dólares. Eu consegui fazer com que ele retorne valores em reais utilizando um proxy brasileiro, mas queria achar uma forma direta, sem usar proxy, pq toda hora tenho que ficar atualizando os ips desses proxys.
<?php
date_default_timezone_set('America/Sao_Paulo');
$link = "";
function curl($url, $proxy) {
$options = Array(
CURLOPT_RETURNTRANSFER => TRUE, // Setting cURL's option to return the webpage data
CURLOPT_FOLLOWLOCATION => TRUE, // Setting cURL to follow 'location' HTTP headers
CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers
CURLOPT_CONNECTTIMEOUT => 300, // Setting the amount of time (in seconds) before the request times out
CURLOPT_TIMEOUT => 300, // Setting the maximum amount of time for cURL to execute queries
CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", // Setting the useragent
CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function
CURLOPT_HTTPPROXYTUNNEL => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
);
$ch = curl_init(); // Initialising cURL
curl_setopt_array($ch, $options);
$data = curl_exec($ch);
if ($data === false) $data = curl_error($ch);
return stripslashes($data);
curl_close($ch);
}
$scraped_page = curl($link);
echo $scraped_page;
?>
Minha última tentativa foi adicionar esses parametros abaixo no final do link, mas sem sucesso.
basecurrency=BRL&prefcurrency=BRL&preflang=536&lang=536&crmActionType=&langCurrencyActionType=currency
Alguém conseguiria me ajudar e possivelmente me explicar o que acontece?
Obrigado!
Discussão (0)
Carregando comentários...