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

namespace App\Models\parserSkripte;

use App\Models\Searchengine;

class Minisucher extends Searchengine
{

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

15
	public function loadResults ($content)
16
	{
17
18
19
20
21
		try {
			$content = simplexml_load_string($content);
		} catch (\Exception $e) {
			return;
		}
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
		if(!$content)
		{
			return;
		}
		$results = $content->xpath('//response/result/doc');

		$string = "";
		
		$counter = 0;
		foreach($results as $result)
		{
			$counter++;
			$result = simplexml_load_string($result->saveXML());
			$title = $result->xpath('//doc/arr[@name="title"]/str')[0]->__toString();
			$link = $result->xpath('//doc/str[@name="url"]')[0]->__toString();
			$anzeigeLink = $link;
			$descr = "";
			$descriptions = $content->xpath("//response/lst[@name='highlighting']/lst[@name='$link']/arr[@name='content']/str");
			foreach($descriptions as $description)
			{
				$descr .= $description->__toString();
			}
			$descr = strip_tags($descr);
			$provider = $result->xpath('//doc/str[@name="subcollection"]')[0]->__toString();
			$this->results[] = new \App\Models\Result(
47
					$this->engine,
48
49
50
51
52
53
54
55
56
57
58
59
60
					$title,
					$link,
					$link,
					$descr,
					$this->gefVon,
					$counter
					);
		}
		
		
	}

}