Commit 89570f40 authored by Karl's avatar Karl

openclipart parser skript kann jetzt als vorlage für absturzsichere parser skripte genutzt werden.

parent fce29d50
......@@ -44,7 +44,7 @@ class Openclipart extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("Results from $this->name are not a valid json string");
Log::error("A problem occurred parsing results from $this->name");
return;
}
}
......@@ -65,7 +65,7 @@ class Openclipart extends Searchengine
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
} catch (\Exception $e) {
Log::error("Results from $this->name are not a valid json string");
Log::error("A problem occurred parsing results from $this->name");
return;
}
}
......
......@@ -17,31 +17,31 @@ class OvertureAds extends Searchengine
$result = preg_replace("/\r\n/si", "", $result);
try {
$content = simplexml_load_string($result);
if (!$content) {
return;
}
$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,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
} catch (\Exception $e) {
abort(500, "$result is not a valid xml string");
}
if (!$content) {
Log::error("A problem occurred parsing results from $this->name");
return;
}
$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,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment