mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 07:09:54 +03:00
Find PanneauPocket city id from page URL (#3825)
Co-authored-by: Guillaume Lacasa <git@adhess.net>
This commit is contained in:
parent
4a398a5b14
commit
a3b064f4ee
1 changed files with 26 additions and 2 deletions
|
@ -12,6 +12,12 @@ class PanneauPocketBridge extends BridgeAbstract
|
|||
'name' => 'Choisir une ville',
|
||||
'type' => 'list',
|
||||
'values' => self::CITIES,
|
||||
],
|
||||
'cityName' => [
|
||||
'name' => 'Ville',
|
||||
],
|
||||
'cityId' => [
|
||||
'name' => 'Identifiant',
|
||||
]
|
||||
]
|
||||
];
|
||||
|
@ -113,8 +119,14 @@ class PanneauPocketBridge extends BridgeAbstract
|
|||
|
||||
public function collectData()
|
||||
{
|
||||
$matchedCity = array_search($this->getInput('cities'), self::CITIES);
|
||||
$city = strtolower($this->getInput('cities') . '-' . $matchedCity);
|
||||
$cityId = $this->getInput('cityId');
|
||||
if ($cityId != null) {
|
||||
$cityName = $this->getInput('cityName');
|
||||
$city = strtolower($cityId . '-' . $cityName);
|
||||
} else {
|
||||
$matchedCity = array_search($this->getInput('cities'), self::CITIES);
|
||||
$city = strtolower($this->getInput('cities') . '-' . $matchedCity);
|
||||
}
|
||||
$url = sprintf('https://app.panneaupocket.com/ville/%s', urlencode($city));
|
||||
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
|
@ -136,6 +148,18 @@ class PanneauPocketBridge extends BridgeAbstract
|
|||
}
|
||||
}
|
||||
|
||||
public function detectParameters($url)
|
||||
{
|
||||
$params = [];
|
||||
$regex = '/\/ville\/(\d+)-([a-z0-9-]+)/';
|
||||
if (preg_match($regex, $url, $matches)) {
|
||||
$params['cityId'] = $matches[1];
|
||||
$params['cityName'] = $matches[2];
|
||||
return $params;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce self::CITIES array
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue