Commit eee7513e authored by Karl's avatar Karl
Browse files

Allesklar wird jetzt wieder fehlerfrei geparsed.

Alle Parser mit try-catch-sicherung geben jetzt den Fehler mit zum Log, statt nur einer allgemeinen Meldung.
parent fd0fd89a
......@@ -20,36 +20,37 @@ class Allesklar extends Searchengine
$crawler = $crawler
->filter('table[width=585]')
->reduce(function (Crawler $node, $i) {
if ($i < 5) {
return false;
}
// The first 5 elements are additional information
return $i >= 5;
});
$this->counter = 0;
$crawler->filter('table')->each(function (Crawler $node, $i) {
try {
$this->string = "";
$titleTag = $node->filter('tr > td > a')->first();
$title = trim($titleTag->filter('a')->text());
$link = $titleTag->filter('a')->attr('href');
if ($i === 0) {
$descr = trim($node->filter('tr > td.bodytext')->eq(3)->text());
} else {
$crawler->each(function (Crawler $node, $i) {
// Only the first 20 elements are actual search results
if ($i < 20) {
try {
$titleTag = $node->filter('tr > td > a.katalogtitel')->first();
$title = trim($titleTag->text());
$link = $titleTag->attr('href');
// Sometimes the description is in the 3rd element
$descr = trim($node->filter('tr > td.bodytext')->eq(2)->text());
if (strlen($descr) <= 2) {
$descr = trim($node->filter('tr > td.bodytext')->eq(3)->text());
}
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$link,
$descr,
$this->gefVon,
$this->counter
);
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$link,
$descr,
$this->gefVon,
$this->counter
);
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
return;
}
});
}
......
......@@ -55,7 +55,8 @@ class BASE extends Searchengine
}
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -36,7 +36,8 @@ class Bing extends Searchengine
);
});
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
......
......@@ -40,7 +40,8 @@ class Blogsearch extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -43,7 +43,8 @@ class Dailymotion extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -59,7 +59,8 @@ class Ebay extends Searchengine
$count++;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -56,7 +56,8 @@ class Ecoshopper extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -50,7 +50,8 @@ class Europeana extends Searchengine
}
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......@@ -72,7 +73,8 @@ class Europeana extends Searchengine
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -70,7 +70,8 @@ class Exalead extends Searchengine
}
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -47,7 +47,8 @@ class Fernsehsuche extends Searchengine
}
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -44,7 +44,8 @@ class Flickr extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......@@ -68,7 +69,8 @@ class Flickr extends Searchengine
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -49,7 +49,8 @@ class Mg_produkt2 extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -44,7 +44,8 @@ class Openclipart extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......@@ -65,7 +66,8 @@ class Openclipart extends Searchengine
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -46,7 +46,8 @@ class Opencrawlastronomie extends Searchengine
$count++;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -46,7 +46,8 @@ class Opencrawlregengergie extends Searchengine
$count++;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -46,7 +46,8 @@ class Opencrawltauchen extends Searchengine
$count++;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -60,7 +60,8 @@ class Overture extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......@@ -73,10 +74,9 @@ class Overture extends Searchengine
if (!$content) {
return;
}
///////////////////
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
......
......@@ -39,7 +39,8 @@ class OvertureAds extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -44,7 +44,8 @@ class Pixabay extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......@@ -75,7 +76,8 @@ class Pixabay extends Searchengine
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
......@@ -40,7 +40,8 @@ class Qip extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name");
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
......
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