Reviews are written by buyers or customers to rate and comment on product that they have purchased. Right on the same page, other customers can read these reviews to make a purchase decision. The review data plays an import role to understand their customers views on specific product and their requirement. Due to the importance, most of the businesses always looking for the review data from different websites or platform to analyse and make future strategy.
But scraping reviews data from different platforms is not an easy task. It’s always a challenge for the developers to develop a system to scrape review data. Also if we try it manually, then its very time consuming as it involves adding several data sources, adaption to markup changes, managing proxy networks etc.
So if you’re running a business and looking for the solution to scrape the reviews data from different websites or platforms, then you’re here at the right place. In this tutorial, you will learn how to easily scrape the reviews data using ReviewAPI with PHP.
The ReviewAPI is a high speed Review Scraping API, developed bySaaS Industries. The Review API provides data scraping services for more than 30 reviews platforms. The major supported reviews platforms to scrape data are Amazon, Google, Yelp, Facebook, Tripadvisor and many more.
Also, read:
So let’s proceed to integrate the ReviewAPI with PHP to scrape the reviews data.
Step1: Get ReviewAPI Access Key
First we will sign up on ReviewAPI to create an account to get the API Key.
We will use the API Key to make the HTTP request to the API.
https://app.reviewapi.io/api/v0/search?apikey=APIKEY
Step2: Create Data Search Query
We need to create the data search query with the parameters to make request to API. We will use parameter url
and pass the website URL to scrape reviews data.
<?php $dataSearchQuery = [ 'url' => 'https://www.yelp.at/biz/teddy-s-red-tacos-los-angeles-2', 'type' => '', ]; ?>
Step3: Make Request to Review API
We need to make HTTP API request with required parameters to scrape the review data. We will make request to ReviewAPI using PHP Curl function and pass API Key and data query with the HTTP request to scrape the reviews data.
<?php $apiAccessKey = "YOUR_API_KEY"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_URL, 'https://app.reviewapi.io/api/v0/reviews?' . http_build_query($dataSearchQuery)); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "apikey: $apiAccessKey", )); $response = curl_exec($ch); curl_close($ch); ?>
Step4: Decode Response Data
We need to decode the response data into JSON. So we will decode the data to JSON using PHP json_decode()
function and store the JSON data into $result
variable.
<?php $result = json_decode($response); var_dump($result); ?>
Step5: Complete Code to Use Review API with PHP
Here is the complete example code to create search query and make HTTP request to ReviewAPI
to scrape the reviews data and get response data into JSON format.
<?php $apiAccessKey = "YOUR_API_KEY"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $dataSearchQuery = [ 'url' => 'https://www.yelp.at/biz/teddy-s-red-tacos-los-angeles-2', 'type' => '', ]; curl_setopt($ch, CURLOPT_URL, 'https://app.reviewapi.io/api/v0/reviews?' . http_build_query($dataSearchQuery)); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "apikey: $apiAccessKey", )); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response); var_dump($result); ?>
Below is the sample reviews data in JSON format using ReviewAPI
.
{ "source": "Google", "reviewAge": "3w" "rating": 2, "maxRating": 5, "reviewerName": "Mr. Miller", "reviewText": "It's amazing...", }, { "source": "Google", "reviewAge": "5w" "rating": 5, "maxRating": 5, "reviewerName": "Mr. Smith", "reviewText": "This is awesome...", }, { "source": "Google", "reviewAge": "4w" "rating": 3, "maxRating": 5, "reviewerName": "Mr. Adam", "reviewText": "Nice experiance...", },
Step6: Conclusion
Here in this tutorial you have learned how to integrate ReviewAPI with PHP to scrape the reviews data. You can also checkout the documentation for more details.
You may also like:
- IP Geolocation API – IPWHOIS.IO
- How to Integrate IP Geolocation API with PHP
- Scrape Search Result Data using SerpApi with Python
- Get Geocoding using Positionstack API with PHP
- Flight Data using Aviationstack API with PHP
- Get Address Information using Geocode API with PHP
- Review Scraping using ReviewAPI with PHP
- Simple Web Scraping with Zenscrape API using PHP
- Scrape Search Result with Zenserp API using PHP
- Build User Agent Lookup System using Userstack API with PHP
- Build IP Lookup Website using ipapi with PHP
- Build Weather Website with Weatherstack API using PHP
- Get Website Visitors Info using IPStack API with PHP
- Scrape SERP Data using SerpStack API with Python