https://github.com/osoobe/dubizzle-php
Dubizzle is an online classifieds website. This project aims to become a simple and complete web scraping API for Dubizzle.
https://github.com/osoobe/dubizzle-php
composer curl-multi curlphp dubizzle motor uae
Last synced: 5 days ago
JSON representation
Dubizzle is an online classifieds website. This project aims to become a simple and complete web scraping API for Dubizzle.
- Host: GitHub
- URL: https://github.com/osoobe/dubizzle-php
- Owner: osoobe
- License: mit
- Created: 2015-08-30T00:30:24.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-22T05:00:10.000Z (almost 10 years ago)
- Last Synced: 2024-11-26T21:35:11.868Z (11 months ago)
- Topics: composer, curl-multi, curlphp, dubizzle, motor, uae
- Language: PHP
- Homepage:
- Size: 59.6 KB
- Stars: 3
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Introduction
[Dubizzle](http://www.dubizzle.com/) is an online classifieds website. This project aims to
become a simple and complete PHP scraping-based API for Dubizzle.This project was enspired by python's [Dubizzle scraping API](https://github.com/Cyph0n/dubizzle/).
## Notice
This is still a work in progress. There is much left to do until this becomes what it should be. I will however make sure that the `master` branch functions as expected. Any help would be greatly appreciated, obviously.
Another thing to point out is that the main focus for the time being is on Dubizzle UAE and specifically Motors search within it.
## Prerequisites
* [php-html-parse](https://github.com/paquettg/php-html-parser)
* [php-curl-class](https://github.com/php-curl-class/php-curl-class)
* [HTMLPurifier](https://packagist.org/packages/ezyang/htmlpurifier)
* PHP 5.3 or greater## Installation
To easily install Dubizzle, simply:
```bash
composer require osoobe/dubizzle
```If you don't have compose install, see [how to install and use composer](https://getcomposer.org/doc/00-intro.md)
## Quickstart
```php
use Dubizzle\Search;
$params = ["country"=>'uae', "city"=>"dubai", "section"=>"motor"];
$uea = new Search($params);
$query = $uea->search();
$query->fetch();$results = $query->get_results();
```
The `$results` variable is a array of associated data for each result item on dubizzle:
```php
var_dump($results);
[
['title' => '...',
'location' => '...',
'url' => '...',
'price' => '...',
'category' => '...'
],
['title' => '...',
'location' => '...',
'url' => '...',
'price' => '...',
'category' => '...'
],
...
]
```See [Demo 1](http://www.osoobe.com/devlabs/php/demo/dubizzle-php/demo/demo.php) for data output.
## Example
Find average price of year 2007 and above Nissan Altimas in Dubai ([Live Demo](http://www.osoobe.com/devlabs/php/demo/dubizzle-php/demo/demo2.php))
```php
require_once "../vendor/autoload.php";use Dubizzle\Search;
$params = [
"keyword"=>'altima',
"country"=>'uae',
"city"=>'dubai',
"section"=>'motors',
"category"=>'cars',
"make"=>'nissan',
"min_year"=>2007,
"num_results"=>'all'];$uae = new Search($params);
$query = $uae->search();
$query->fetch();
$results = $query->get_results();$result_count = count($results);
$total_price = 0;
foreach($results as $result){
$total_price += $result["price"];
}echo "Num. Results: ".$result_count;
echo "
";
echo "
";
echo "Average price: ".(intval($total_price / $result_count)); # Prints 39239.94
```## Other Examples
Get the list of makes from [Dubizzle] ([Live Demo](http://www.osoobe.com/devlabs/php/demo/dubizzle-php/demo/get_makes.php)):
```phpuse Dubizzle\Category;
$category = new Category();
$makes = $category->get_makes(Category::$uae["categories"]["options"]['cars']);
```Get the list of models from [Dubizzle] ([Live Demo](http://www.osoobe.com/devlabs/php/demo/dubizzle-php/demo/get_models.php)):
```phpuse Dubizzle\Category;
$category = new Category();
$models = $category->get_models(Category::$uae["makes"]["options"]['audi']);
```## Search Parameters
### General
* `country` - string; defaults to 'uae'
* `keyword` - string
* `city` - string
* `section` - string
* `min_price` and `max_price` - integers
* `category` - string
* `added_days` - choices are 0, 3, 7, 14, 30, 90, or 180
* `num_results` - integer; 'all' fetches all results available
* `detailed` (not implemented) - if set to `True`, fetches full listing data for each result; slower, obviously### Motors
* `make` - a long list can be found in `regions.py`
* `min_year` and `max_year` - integers
* `min_kms` and `max_kms` - integers
* `seller` - 'dealer' or 'owner'
* `fuel` - 'gasoline', 'hybrid', 'diesel', or 'electric'
* `cylinders` - 3, 4, 5, 6, 8, 10, or 12
* `transmission` - 'automatic' or 'manual'## Listing Parameters
* `url` - string, **required**
* `country` - string; defaults to 'uae'## Issues
Please use the [Issues](https://github.com/Osoobe/dubizzle-php/issues) page for that.