From 4825a92010a8871f95f691fdd92c30317f00e89c Mon Sep 17 00:00:00 2001
From: Karl <Karl Hasselbring>
Date: Thu, 12 Jan 2017 10:28:47 +0100
Subject: [PATCH] Allesklar wird jetzt wieder fehlerfrei geparsed. Alle Parser
 mit try-catch-sicherung geben jetzt den Fehler mit zum Log, statt nur einer
 allgemeinen Meldung.

---
 app/Models/parserSkripte/Allesklar.php        | 53 ++++++++++---------
 app/Models/parserSkripte/BASE.php             |  3 +-
 app/Models/parserSkripte/Bing.php             |  3 +-
 app/Models/parserSkripte/Blogsearch.php       |  3 +-
 app/Models/parserSkripte/Dailymotion.php      |  3 +-
 app/Models/parserSkripte/Ebay.php             |  3 +-
 app/Models/parserSkripte/Ecoshopper.php       |  3 +-
 app/Models/parserSkripte/Europeana.php        |  6 ++-
 app/Models/parserSkripte/Exalead.php          |  3 +-
 app/Models/parserSkripte/Fernsehsuche.php     |  3 +-
 app/Models/parserSkripte/Flickr.php           |  6 ++-
 app/Models/parserSkripte/Mg_produkt2.php      |  3 +-
 app/Models/parserSkripte/Openclipart.php      |  6 ++-
 .../parserSkripte/Opencrawlastronomie.php     |  3 +-
 .../parserSkripte/Opencrawlregengergie.php    |  3 +-
 app/Models/parserSkripte/Opencrawltauchen.php |  3 +-
 app/Models/parserSkripte/Overture.php         |  8 +--
 app/Models/parserSkripte/OvertureAds.php      |  3 +-
 app/Models/parserSkripte/Pixabay.php          |  6 ++-
 app/Models/parserSkripte/Qip.php              |  3 +-
 app/Models/parserSkripte/Radiobrowser.php     |  3 +-
 app/Models/parserSkripte/Tuhh.php             |  3 +-
 app/Models/parserSkripte/Yacy.php             |  3 +-
 app/Models/parserSkripte/Yacyunih.php         |  3 +-
 app/Models/parserSkripte/Yandex.php           |  6 ++-
 25 files changed, 87 insertions(+), 58 deletions(-)

diff --git a/app/Models/parserSkripte/Allesklar.php b/app/Models/parserSkripte/Allesklar.php
index 6f78151e3..2f5bb9e2c 100644
--- a/app/Models/parserSkripte/Allesklar.php
+++ b/app/Models/parserSkripte/Allesklar.php
@@ -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;
             }
         });
     }
diff --git a/app/Models/parserSkripte/BASE.php b/app/Models/parserSkripte/BASE.php
index c1cf610a4..b63345cf2 100644
--- a/app/Models/parserSkripte/BASE.php
+++ b/app/Models/parserSkripte/BASE.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Bing.php b/app/Models/parserSkripte/Bing.php
index fcdce0dce..b31946faa 100644
--- a/app/Models/parserSkripte/Bing.php
+++ b/app/Models/parserSkripte/Bing.php
@@ -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;
         }
 
diff --git a/app/Models/parserSkripte/Blogsearch.php b/app/Models/parserSkripte/Blogsearch.php
index a6cc51d4c..3f6f16edb 100644
--- a/app/Models/parserSkripte/Blogsearch.php
+++ b/app/Models/parserSkripte/Blogsearch.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Dailymotion.php b/app/Models/parserSkripte/Dailymotion.php
index f249c1038..fbd6247f0 100644
--- a/app/Models/parserSkripte/Dailymotion.php
+++ b/app/Models/parserSkripte/Dailymotion.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Ebay.php b/app/Models/parserSkripte/Ebay.php
index 8a1cfa342..14c181b13 100644
--- a/app/Models/parserSkripte/Ebay.php
+++ b/app/Models/parserSkripte/Ebay.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Ecoshopper.php b/app/Models/parserSkripte/Ecoshopper.php
index fca12fbbd..47f0c4073 100644
--- a/app/Models/parserSkripte/Ecoshopper.php
+++ b/app/Models/parserSkripte/Ecoshopper.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Europeana.php b/app/Models/parserSkripte/Europeana.php
index 3aa5d10d6..79ebc6c14 100644
--- a/app/Models/parserSkripte/Europeana.php
+++ b/app/Models/parserSkripte/Europeana.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Exalead.php b/app/Models/parserSkripte/Exalead.php
index 6ba8b3b19..0418f497f 100644
--- a/app/Models/parserSkripte/Exalead.php
+++ b/app/Models/parserSkripte/Exalead.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Fernsehsuche.php b/app/Models/parserSkripte/Fernsehsuche.php
index b195a89c4..deb92f0c9 100644
--- a/app/Models/parserSkripte/Fernsehsuche.php
+++ b/app/Models/parserSkripte/Fernsehsuche.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Flickr.php b/app/Models/parserSkripte/Flickr.php
index ad6c00f6f..55540a350 100644
--- a/app/Models/parserSkripte/Flickr.php
+++ b/app/Models/parserSkripte/Flickr.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Mg_produkt2.php b/app/Models/parserSkripte/Mg_produkt2.php
index 4e1751cf5..f6e39e48f 100644
--- a/app/Models/parserSkripte/Mg_produkt2.php
+++ b/app/Models/parserSkripte/Mg_produkt2.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Openclipart.php b/app/Models/parserSkripte/Openclipart.php
index f2b44ce1f..6f8135487 100644
--- a/app/Models/parserSkripte/Openclipart.php
+++ b/app/Models/parserSkripte/Openclipart.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Opencrawlastronomie.php b/app/Models/parserSkripte/Opencrawlastronomie.php
index 47d101249..4667e241a 100644
--- a/app/Models/parserSkripte/Opencrawlastronomie.php
+++ b/app/Models/parserSkripte/Opencrawlastronomie.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Opencrawlregengergie.php b/app/Models/parserSkripte/Opencrawlregengergie.php
index b261b3151..92dee253c 100644
--- a/app/Models/parserSkripte/Opencrawlregengergie.php
+++ b/app/Models/parserSkripte/Opencrawlregengergie.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Opencrawltauchen.php b/app/Models/parserSkripte/Opencrawltauchen.php
index b947c36f7..433948756 100644
--- a/app/Models/parserSkripte/Opencrawltauchen.php
+++ b/app/Models/parserSkripte/Opencrawltauchen.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Overture.php b/app/Models/parserSkripte/Overture.php
index 4685f4837..791e5b41f 100644
--- a/app/Models/parserSkripte/Overture.php
+++ b/app/Models/parserSkripte/Overture.php
@@ -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;
         }
 
diff --git a/app/Models/parserSkripte/OvertureAds.php b/app/Models/parserSkripte/OvertureAds.php
index d11b42b06..dcca4fa38 100644
--- a/app/Models/parserSkripte/OvertureAds.php
+++ b/app/Models/parserSkripte/OvertureAds.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Pixabay.php b/app/Models/parserSkripte/Pixabay.php
index ea0cd2d1a..8fd708772 100644
--- a/app/Models/parserSkripte/Pixabay.php
+++ b/app/Models/parserSkripte/Pixabay.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Qip.php b/app/Models/parserSkripte/Qip.php
index b786656ee..7e818042a 100644
--- a/app/Models/parserSkripte/Qip.php
+++ b/app/Models/parserSkripte/Qip.php
@@ -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;
         }
     }
diff --git a/app/Models/parserSkripte/Radiobrowser.php b/app/Models/parserSkripte/Radiobrowser.php
index fb9d5edcd..ba49319b9 100644
--- a/app/Models/parserSkripte/Radiobrowser.php
+++ b/app/Models/parserSkripte/Radiobrowser.php
@@ -56,7 +56,8 @@ class Radiobrowser 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;
         }
     }
diff --git a/app/Models/parserSkripte/Tuhh.php b/app/Models/parserSkripte/Tuhh.php
index 05c8bc326..75cf37c59 100644
--- a/app/Models/parserSkripte/Tuhh.php
+++ b/app/Models/parserSkripte/Tuhh.php
@@ -45,7 +45,8 @@ class Tuhh 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;
         }
     }
diff --git a/app/Models/parserSkripte/Yacy.php b/app/Models/parserSkripte/Yacy.php
index 83f0c5a6d..57558f992 100644
--- a/app/Models/parserSkripte/Yacy.php
+++ b/app/Models/parserSkripte/Yacy.php
@@ -45,7 +45,8 @@ class Yacy 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;
         }
     }
diff --git a/app/Models/parserSkripte/Yacyunih.php b/app/Models/parserSkripte/Yacyunih.php
index a8585f4f3..58c5531ac 100644
--- a/app/Models/parserSkripte/Yacyunih.php
+++ b/app/Models/parserSkripte/Yacyunih.php
@@ -48,7 +48,8 @@ class Yacyunih 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;
         }
     }
diff --git a/app/Models/parserSkripte/Yandex.php b/app/Models/parserSkripte/Yandex.php
index acf4bc0bc..6553d09cf 100644
--- a/app/Models/parserSkripte/Yandex.php
+++ b/app/Models/parserSkripte/Yandex.php
@@ -44,7 +44,8 @@ class Yandex 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 Yandex extends Searchengine
             $next->getString .= "&page=" . ($metager->getPage() + 1);
             $next->hash = md5($next->host . $next->getString . $next->port . $next->name);
         } 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;
         }
     }
-- 
GitLab