This endpoint will retrieve news data from a Google news result page and transform it into usable JSON.
Copy <?php
$curl = curl_init();
$data = json_encode(array(
'apiKey' => 'APIKEY',
'query' => 'QUERY',
'tld' => 'TLD',
'uule' => 'UULE',
'num' => 'NUM',
'hl' => 'HOSTLANGUAGE',
'gl' => 'GUESTLANGUAGE',
'ie' => 'QUERYENCODING',
'oe' => 'RESULTENCODING',
'start' => 'START',
'callback' => array(
'type' => 'webhook',
'url' => 'CALLBACK'
)
));
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl);
} else {
echo $response;
}
curl_close($curl);
?>
Copy <?php
$curl = curl_init();
$data = json_encode(array(
'apiKey' => 'APIKEY',
'queries' => array('QUERY1', 'QUERY2', 'QUERY3'),
'tld' => 'TLD',
'uule' => 'UULE',
'num' => 'NUM',
'hl' => 'HOSTLANGUAGE',
'gl' => 'GUESTLANGUAGE',
'ie' => 'QUERYENCODING',
'oe' => 'RESULTENCODING',
'start' => 'START',
'callback' => array(
'type' => 'webhook',
'url' => 'CALLBACK'
)
));
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl);
} else {
echo $response;
}
curl_close($curl);
?>