fix: a bunch of small changes in multiple bridges (#2644)

Mostly refactors.
This commit is contained in:
Dag 2022-04-12 23:37:30 +02:00 committed by GitHub
parent 5b7dd45b20
commit b6e8350596
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 81 additions and 46 deletions

View file

@ -17,21 +17,24 @@ class ViadeoCompanyBridge extends BridgeAbstract {
));
public function collectData(){
$html = '';
$link = self::URI . 'fr/company/' . $this->getInput('c');
// Redirects to https://emploi.lefigaro.fr/recherche/entreprises
$url = sprintf('%sfr/company/%s', self::URI, $this->getInput('c'));
$html = getSimpleHTMLDOM($link);
$html = getSimpleHTMLDOM($url);
foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) {
// TODO: Fix broken xpath selector
$elements = $html->find('//*[@id="company-newsfeed"]/ul/li');
foreach($elements as $element) {
$title = $element->find('p', 0)->innertext;
if($title) {
$item = array();
$item['uri'] = $link;
$item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100);
$item['content'] = $element->find('p', 0)->innertext;;
$this->items[] = $item;
$i++;
if(!$title) {
continue;
}
$item = array();
$item['uri'] = $url;
$item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100);
$item['content'] = $element->find('p', 0)->innertext;;
$this->items[] = $item;
}
}
}