From 9e063918871a1098dbeede3d5e4e2fb13f75ed9d Mon Sep 17 00:00:00 2001 From: Dominik Pfennig <dominik@suma-ev.de> Date: Wed, 12 Oct 2016 09:49:59 +0200 Subject: [PATCH] =?UTF-8?q?Parser=20f=C3=BCr=20Blogsuche=20eingebaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/parserSkripte/Blogsearch.php | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/Models/parserSkripte/Blogsearch.php diff --git a/app/Models/parserSkripte/Blogsearch.php b/app/Models/parserSkripte/Blogsearch.php new file mode 100644 index 000000000..c167afc24 --- /dev/null +++ b/app/Models/parserSkripte/Blogsearch.php @@ -0,0 +1,49 @@ +<?php + +namespace app\Models\parserSkripte; + +use App\Models\Searchengine; + +class Blogsearch extends Searchengine +{ + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $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('//xml/docs/doc'); + # die(var_dump($results)); + foreach ($results as $result) { + $title = $result->{"title"}->__toString(); + $link = $result->{"url"}->__toString(); + $anzeigeLink = $link; + $descr = $result->{"content"}->__toString(); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } + +} -- GitLab