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

Yandex Parser eingefügt

parent eb07078c
No related branches found
No related tags found
2 merge requests!111Development,!110Yandex Parser eingefügt
...@@ -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 Yandex extends Searchengine class Yandex extends Searchengine
{ {
...@@ -14,22 +15,40 @@ class Yandex extends Searchengine ...@@ -14,22 +15,40 @@ class Yandex 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); try{
$results = $results->xpath("//yandexsearch/response/results/grouping/group");
/*$this->counter++; } catch(\ErrorException $e)
$this->results[] = new \App\Models\Result( {
$title, return;
$link, }
$anzeigeLink, foreach($results as $result)
$descr, {
$this->gefVon, $title = strip_tags($result->{"doc"}->{"title"}->asXML());
$this->counter $link = $result->{"doc"}->{"url"}->__toString();
);*/ $anzeigeLink = $link;
$descr = strip_tags($result->{"doc"}->{"headline"}->asXML());
$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