From a31b2bfc557b38292221d773b54f08ad6a756b81 Mon Sep 17 00:00:00 2001 From: mitterhuemer Date: Thu, 30 Mar 2017 21:21:29 +0200 Subject: [PATCH] Update source-Herold_Austria.module (#296) --- sources/source-Herold_Austria.module | 58 ++++++++++++++++++---------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/sources/source-Herold_Austria.module b/sources/source-Herold_Austria.module index 1acc4d80..615f2f7b 100644 --- a/sources/source-Herold_Austria.module +++ b/sources/source-Herold_Austria.module @@ -4,9 +4,9 @@ * Developer Notes: * * There are two separate URLS for reverse searching, one for yellowpages one for ppl: - * http://www.herold.at/en/telefonbuch/telefon_$thenumber - people - * http://www.herold.at/en/gelbe-seiten/telefon_$thenumber - business - * I could only get reverse searches to work for ppl + * http://www.herold.at/en/telefonbuch/telefon_$thenumber - people + * http://www.herold.at/en/gelbe-seiten/telefon_$thenumber - business + * I could only get reverse searches to work for ppl * * herold.at Terms of Service: * As summarized in the post here on 2014-06-27 @@ -16,36 +16,54 @@ * Version History: * 2014-06-28 Initial migration from 2.2.x * 2014-07-02 Add business lookups and change urls to mobile site - * + * 2016-05-03 Rewrite Numbers correct for Herold and change Query for new Mobile Web Template + * 2017-03-20 Again Herold has a new Theme. We need to change the regexp again *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/ - class Herold_Austria extends superfecta_base { public $description; public $version_requirement = "2.11"; public function __construct() { - $this->description = "http://www.herold.at/ - "._("These listings include data for Austria."); + $this->description = "https://www.herold.at/ - "._("These listings include data for Austria."); } - function get_caller_id($thenumber, $run_param=array()) { - $this->DebugPrint(_("Searching"). "http://www.herold.at/ ... "); + function get_caller_id($thenumber, $run_param=array()) { + $this->DebugPrint(_("Searching"). "https://www.herold.at/ ... "); - // Set the url we're searching for - $res_rul = "http://www.herold.mobi/telefonbuch/was_$thenumber/"; // url for searching residential listings - $bus_url = "http://www.herold.mobi/gelbe-seiten/was_$thenumber/"; // url for searching business listings + if (substr($thenumber, 0, 1) ==! '0') { + $thenumber=trim($thenumber,' '); + $thenumber="00" . $thenumber; + } + if (substr($thenumber, 0, 2) === '00') { + $thenumber=trim($thenumber,' '); + } - // regex patterns to search for - $regexp = array( - '~>(.*?) ~', - ); + // Set the url we're searching for + $res_rul = "https://www.herold.at/telefonbuch/was_".$thenumber."/";// url for searching residential listings + $bus_url = "https://www.herold.at/gelbe-seiten/was_".$thenumber."/";// url for searching business listings - $caller_id=""; - // first search for Residential match - if ($this->SearchURL($res_rul, $regexp, $match)) { - $caller_id = $this->ExtractMatch($match); - } + // regex patterns to search for + $regexp = array( + '~

(.+?)~', + ); + + // first search for Residential match + if ($this->SearchURL($res_rul, $regexp, $match)) { + $caller_id = $this->ExtractMatch($match); + } + + // if no residential match found, search business + if ($this->SearchURL($bus_url, $regexp, $match)) { + $caller_id = $this->ExtractMatch($match); + } + $caller_id = isset($caller_id)?$caller_id:''; + + return($caller_id); + } + +} // if no residential match found, search business if (!$caller_id && $this->SearchURL($bus_url, $regexp, $match)) {