-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
35 lines (29 loc) · 1.01 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require __DIR__.'/vendor/autoload.php';
use SearchResultsAggregator\WebDrivers\Phantomjs as PhantomjsDriver;
use SearchResultsAggregator\DataProviders\{Google, Yahoo, GroupDataProvider};
use SearchResultsAggregator\Aggregator;
$searchRequestString = $argv[1] ?? '';
if (empty($searchRequestString)) {
echo "No search request.\n";
die;
}
$dataProvider = new Google(new PhantomjsDriver('http://phantomjs:8910'));
$results = $dataProvider->search($searchRequestString);
foreach ($results as $result) {
$result->print();
}
$dataProvider = new Yahoo(new PhantomjsDriver('http://phantomjs:8910'));
$results = $dataProvider->search($searchRequestString);
foreach ($results as $result) {
$result->print();
}
$groupDataProvider = new GroupDataProvider(
new Aggregator(),
new Google(new PhantomjsDriver('http://phantomjs:8910')),
new Yahoo(new PhantomjsDriver('http://phantomjs:8910'))
);
$results = $groupDataProvider->search($searchRequestString);
foreach ($results as $result) {
$result->print();
}