Using Google AutocompleAPI you can scrape Google News results without worrying about proxy rotation and data parsing. Our API is fast and reliable. Each successful request will cost you 5 API credits.
import requestsapi_key ="5eaa61a6e562fc52fe763tr516e4653"url ="https://api.scrapingdog.com/google_autocomplete"params ={"api_key": api_key,"query":"football","country":"us"}response = requests.get(url, params=params)if response.status_code ==200: data = response.json()print(data)else:print(f"Request failed with status code: {response.status_code}")
constaxios=require('axios');constapi_key='5eaa61a6e562fc52fe763tr516e4653';consturl='https://api.scrapingdog.com/google_autocomplete';constparams= { api_key: api_key, query:'football', country:'us'};axios.get(url, { params: params }).then(function (response) {if (response.status ===200) {constdata=response.data;console.log(data) } else {console.log('Request failed with status code: '+response.status); } }).catch(function (error) {console.error('Error making the request: '+error.message); });
<?php// Set the API key and request parameters$api_key ='5eaa61a6e562fc52fe763tr516e4653';$query ='football';$country ='us';// Set the API endpoint$url = 'https://api.scrapingdog.com/google_autocomplete/?api_key=' . $api_key . '&query=' . $query . '&country=' . $country;
// Initialize cURL session$ch =curl_init($url);// Set cURL optionscurl_setopt($ch, CURLOPT_RETURNTRANSFER,true);// Execute the cURL request$response =curl_exec($ch);// Check if the request was successfulif ($response ===false) {echo'cURL error: '.curl_error($ch);} else {// Process the response data as neededecho $response;}// Close the cURL sessioncurl_close($ch);
require'net/http'require'uri'# Set the API key and request parametersapi_key ='5eaa61a6e562fc52fe763tr516e4653'query ='football'country ='us'# Construct the API endpoint URLurl = URI.parse("https://api.scrapingdog.com/google_autocomplete/?api_key=#{api_key}&query=#{query}&country=#{country}")
# Create an HTTP GET requestrequest =Net::HTTP::Get.new(url)# Create an HTTP clienthttp =Net::HTTP.new(url.host, url.port)http.use_ssl =true# Enable SSL (https)# Send the request and get the responseresponse = http.request(request)# Check if the request was successfulif response.is_a?(Net::HTTPSuccess)puts response.body # Process the response data as neededelseputs"HTTP request failed with code: #{response.code}, message: #{response.message}"end
importjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.net.HttpURLConnection;importjava.net.URL;importjava.io.IOException;publicclassMain {publicstaticvoidmain(String[] args) {try {// Set the API key and request parametersString apiKey ="5eaa61a6e562fc52fe763tr516e4653";String query ="football"String country ="us";// Construct the API endpoint URLString apiUrl ="https://api.scrapingdog.com/google_autocomplete/?api_key="+ apiKey+"&query="+ query+"&country="+ country// Create a URL object from the API URL stringURL url =newURL(apiUrl);// Open a connection to the URLHttpURLConnection connection = (HttpURLConnection) url.openConnection();// Set the request method to GETconnection.setRequestMethod("GET");// Get the response codeint responseCode =connection.getResponseCode();if (responseCode ==200) {// Read the response from the connectionBufferedReader reader =newBufferedReader(new InputStreamReader(connection.getInputStream()));String inputLine;StringBuilder response =newStringBuilder();while ((inputLine =reader.readLine()) !=null) {response.append(inputLine); }reader.close();// Process the response data as neededSystem.out.println(response.toString()); } else {System.out.println("HTTP request failed with response code: "+ responseCode); }// Close the connectionconnection.disconnect(); } catch (IOException e) {e.printStackTrace(); } }}