import requestsfrom pprint import pprint# Structure payload.payload ={"source":"universal_ecommerce",# Source you choose e.g. "universal_ecommerce""url":"https://example.com",# Check the docs of the specific source you're using to see if you should use "url" or "query""geo_location":"United States",# Some sources accept post codes and/or coordinates#"render" : "html", # Uncomment if you want to render JavaScript on the page#"render" : "png", # Uncomment if you want to take a screenshot of a scraped web page#"parse" : true, # Check what sources support parsed data}# Get response.response = requests.request('POST','https://realtime.oxylabs.io/v1/queries', auth=('YOUR_USERNAME', 'YOUR_PASSWORD'), #Your credentials go here json=payload,)# Instead of response with job status and results url, this will return the# JSON response with results.pprint(response.json())
<?php$params =array('source'=>'universal_ecommerce',//Source you choose e.g. "universal_ecommerce"'url'=>'https://example.com',// Check the docs of the specific source you're using to see if you should use "url" or "query"'geo_location'=>'United States',//Some sources accept zip-code or coordinates//'render' : 'html', // Uncomment if you want to render JavaScript within the page//'render' : 'png', // Uncomment if you want to take a screenshot of a scraped web page//'parse' : TRUE, // Check what sources support parsed data);$ch =curl_init();curl_setopt($ch, CURLOPT_URL,"https://realtime.oxylabs.io/v1/queries");curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));curl_setopt($ch, CURLOPT_POST,1);curl_setopt($ch, CURLOPT_USERPWD,"YOUR_USERNAME".":"."YOUR_PASSWORD"); //Your credentials go here$headers =array();$headers[] ="Content-Type: application/json";curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);$result =curl_exec($ch);echo $result;if (curl_errno($ch)) {echo'Error:'.curl_error($ch);}curl_close ($ch);PHP
Realtime API supports these result types in the output:
HTML: The raw HTML content scraped from the target webpage;
JSON: Structured data parsed from the HTML content, formatted in JSON format;
PNG: Base64-encoded screenshot of the rendered page in PNG format.
This table explains the default and other available result types based on the parameters included in the payload of the API request.
Render parameter
Parse parameter
Default output
Available output
x
x
html
html
html
x
html
html
png
x
png
html, png
x
true
json
html, json
html
true
json
html, json
png
true
png
html, json, png
Realtime API always returns the default output. To get other available outputs from the same realtime job, use Push-Pull endpoints with that job ID. Note that the job ID can be found in the headers of each realtime response as well as within the response body.