mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-10 08:58:50 +00: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
@ -12,6 +12,12 @@ class PanneauPocketBridge extends BridgeAbstract
|
|||||||
'name' => 'Choisir une ville',
|
'name' => 'Choisir une ville',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'values' => self::CITIES,
|
'values' => self::CITIES,
|
||||||
|
],
|
||||||
|
'cityName' => [
|
||||||
|
'name' => 'Ville',
|
||||||
|
],
|
||||||
|
'cityId' => [
|
||||||
|
'name' => 'Identifiant',
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -113,8 +119,14 @@ class PanneauPocketBridge extends BridgeAbstract
|
|||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$matchedCity = array_search($this->getInput('cities'), self::CITIES);
|
$cityId = $this->getInput('cityId');
|
||||||
$city = strtolower($this->getInput('cities') . '-' . $matchedCity);
|
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));
|
$url = sprintf('https://app.panneaupocket.com/ville/%s', urlencode($city));
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($url);
|
$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
|
* Produce self::CITIES array
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user