Using Google News API 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.
You have to send a GET request to http://api.scrapingdog.com/google_shopping with the below-given parameters.
Your personal API key. Available on your dashboard
Type: String
query
required
This can be any Google query or a complete Google URL. Example1 - query=shoes
country
Type - String
page
This is the page number of Google searches. Its value can be 0 for the first page, 1 for the second page, and so on.
Default Value - 0
Type - String
domain
To obtain local results from a specific country, for example, for India, it will be "google.co.in," and for the UK, it will be "google.co.uk".
Type: String
Default: "google.com"
language
Language of the results. Possible Values - en, es, fr, de, etc.
Default Value - en
Type - String
lr
Type: String Limit the search to one or multiple languages.
It is used as lang_{language code}.
For example - "lang_us"
result_time
The "tbs" parameter is often accompanied by additional parameters that define specific search options.
These options can include parameters such as time range, language, country, file type, and more.
Possible Value - qdr:d
Type - String
uule
It is a parameter that specifies the geographic location or locale for which the search results should be tailored. Possible Value could be w+CAIQIFJlbGF5IFN0YXRlcw==
Type - String
tbs
to be searched - An advanced parameter to filter search results.
Type: String
safe
To filter the adult content set safe to active or to disable it set off.
Type: String [active/off]
Default: off
nfpr
It can be set to 1 to exclude these results or 0 to include them.
Type: Boolean
Default: 0 It excludes the result from an auto-corrected query that is spelled wrong.
<?php
// Set the API key and request parameters
$api_key = '5eaa61a6e562fc52fe763tr516e4653';
$query = 'shoes';
$results = 10;
$country = 'in';
// Set the API endpoint
$url = 'https://api.scrapingdog.com/google_shopping/?api_key=' . $api_key . '&query=' . $query . '&results=' . $results . '&country=' . $country;
// Initialize cURL session
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL request
$response = curl_exec($ch);
// Check if the request was successful
if ($response === false) {
echo 'cURL error: ' . curl_error($ch);
} else {
// Process the response data as needed
echo $response;
}
// Close the cURL session
curl_close($ch);
require 'net/http'
require 'uri'
# Set the API key and request parameters
api_key = '5eaa61a6e562fc52fe763tr516e4653'
query = 'shoes'
results = 10
country = 'in'
# Construct the API endpoint URL
url = URI.parse("https://api.scrapingdog.com/google_shopping/?api_key=#{api_key}&query=#{query}&results=#{results}&country=#{country}")
# Create an HTTP GET request
request = Net::HTTP::Get.new(url)
# Create an HTTP client
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true # Enable SSL (https)
# Send the request and get the response
response = http.request(request)
# Check if the request was successful
if response.is_a?(Net::HTTPSuccess)
puts response.body # Process the response data as needed
else
puts "HTTP request failed with code: #{response.code}, message: #{response.message}"
end
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
// Set the API key and request parameters
String apiKey = "5eaa61a6e562fc52fe763tr516e4653";
String query = "shoes";
int results = 10;
String country = "in";
// Construct the API endpoint URL
String apiUrl = "https://api.scrapingdog.com/google_shopping/?api_key=" + apiKey
+ "&query=" + query
+ "&results=" + results
+ "&country=" + country
// Create a URL object from the API URL string
URL url = new URL(apiUrl);
// Open a connection to the URL
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set the request method to GET
connection.setRequestMethod("GET");
// Get the response code
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
// Read the response from the connection
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = reader.readLine()) != null) {
response.append(inputLine);
}
reader.close();
// Process the response data as needed
System.out.println(response.toString());
} else {
System.out.println("HTTP request failed with response code: " + responseCode);
}
// Close the connection
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}