Overture.php 1.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Log;

class Overture extends Searchengine 
{
	public $results = [];

	function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager)
	{
		parent::__construct($engine, $metager);
	}

16
	public function loadResults ($result)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
	{
		$result = preg_replace("/\r\n/si", "", $result);
		try {
			$content = simplexml_load_string($result);
		} catch (\Exception $e) {
			abort(500, "$result is not a valid xml string");
		}
		
		if(!$content)
		{
			return;
		}
		$results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing');
		foreach($results as $result)
		{
			$title = $result["title"];
			$link = $result->{"ClickUrl"}->__toString();
			$anzeigeLink = $result["siteHost"];
			$descr = $result["description"];
			$this->counter++;
			$this->results[] = new \App\Models\Result(
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
				$this->engine,
				$title,
				$link,
				$anzeigeLink,
				$descr,
				$this->gefVon,
				$this->counter
			);
		}

		# Nun noch die Werbeergebnisse:
		$ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing');
		foreach($ads as $ad)
		{
			$title = $ad["title"];
			$link = $ad->{"ClickUrl"}->__toString();
			$anzeigeLink = $ad["siteHost"];
			$descr = $ad["description"];
			$this->counter++;
			$this->ads[] = new \App\Models\Result(
				$this->engine,
59
60
61
62
63
64
65
66
67
68
				$title,
				$link,
				$anzeigeLink,
				$descr,
				$this->gefVon,
				$this->counter
			);
		}
	}
}