Skip to content
Snippets Groups Projects
Commit c253d9be authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Exalead Parser eingefügt

parent 4395b850
No related branches found
No related tags found
2 merge requests!111Development,!108Resolve "Exalead funktioniert nicht"
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace app\Models\parserSkripte; namespace app\Models\parserSkripte;
use App\Models\Searchengine; use App\Models\Searchengine;
use Log;
class Exalead extends Searchengine class Exalead extends Searchengine
{ {
...@@ -14,22 +15,49 @@ class Exalead extends Searchengine ...@@ -14,22 +15,49 @@ class Exalead extends Searchengine
public function loadResults ($result) 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");
}
$title = ""; if(!$content)
$link = ""; {
$anzeigeLink = $link; return;
$descr = ""; }
$results = $content;
#die($result); $prefix = ""; $namespace = "";
foreach($results->getDocNamespaces() as $strPrefix => $strNamespace) {
/*$this->counter++; if(strlen($strPrefix)==0) {
$this->results[] = new \App\Models\Result( $prefix="a"; //Assign an arbitrary namespace prefix.
$title, }else {
$link, $prefix="a";
$anzeigeLink, }
$descr, $namespace = $strNamespace;
$this->gefVon, }
$this->counter $results->registerXPathNamespace($prefix,$namespace);
); */ $results = $results->xpath("//a:hits/a:Hit");
foreach($results as $result)
{
$result->registerXPathNamespace($prefix,$namespace);
$title = $result->xpath("a:metas/a:Meta[@name='title']/a:MetaString[@name='value']")[0]->__toString();
$link = $result->xpath("a:metas/a:Meta[@name='url']/a:MetaString[@name='value']")[0]->__toString();
$anzeigeLink = $link;
if(sizeOf($result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")) === 0)
$descr = "";
else
$descr = $result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")[0]->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment