mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-01 11:02:56 +00:00
Merge 583e5b144f
into 354cea09a7
This commit is contained in:
commit
9e59011719
@ -72,15 +72,9 @@ class CentreFranceBridge extends BridgeAbstract
|
|||||||
$newspaperUrl = 'https://www.' . $this->getInput('newspaper') . '/' . $localitySlug . '/';
|
$newspaperUrl = 'https://www.' . $this->getInput('newspaper') . '/' . $localitySlug . '/';
|
||||||
$html = getSimpleHTMLDOM($newspaperUrl);
|
$html = getSimpleHTMLDOM($newspaperUrl);
|
||||||
|
|
||||||
// Articles are detected through their titles
|
// Articles are detected through a standard tag
|
||||||
foreach ($html->find('.c-titre') as $articleTitleDOMElement) {
|
foreach ($html->find('article') as $articleDOMElement) {
|
||||||
$articleLinkDOMElement = $articleTitleDOMElement->find('a', 0);
|
$articleLinkDOMElement = $articleDOMElement->find('a', 0);
|
||||||
|
|
||||||
// Ignore articles in the « Les + partagés » block
|
|
||||||
if (strpos($articleLinkDOMElement->id, 'les_plus_partages') !== false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$articleURI = $articleLinkDOMElement->href;
|
$articleURI = $articleLinkDOMElement->href;
|
||||||
|
|
||||||
// If the URI has already been processed, ignore it
|
// If the URI has already been processed, ignore it
|
||||||
@ -96,7 +90,7 @@ class CentreFranceBridge extends BridgeAbstract
|
|||||||
$articleTitle = '';
|
$articleTitle = '';
|
||||||
|
|
||||||
// If article is reserved for subscribers
|
// If article is reserved for subscribers
|
||||||
if ($articleLinkDOMElement->find('span.premium-picto', 0)) {
|
if ($articleLinkDOMElement->find('span.premium-icon', 0)) {
|
||||||
if ($this->getInput('remove-reserved-for-subscribers-articles') === true) {
|
if ($this->getInput('remove-reserved-for-subscribers-articles') === true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -104,18 +98,22 @@ class CentreFranceBridge extends BridgeAbstract
|
|||||||
$articleTitle .= '🔒 ';
|
$articleTitle .= '🔒 ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$articleTitleDOMElement = $articleLinkDOMElement->find('span[data-tb-title]', 0);
|
|
||||||
if ($articleTitleDOMElement === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($limit > 0 && count($this->items) === $limit) {
|
if ($limit > 0 && count($this->items) === $limit) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$articleTitle .= $articleLinkDOMElement->find('span[data-tb-title]', 0)->innertext;
|
// Loop through each possible title class name
|
||||||
$articleFullURI = urljoin('https://www.' . $this->getInput('newspaper') . '/', $articleURI);
|
for ($i = 1; $i <= 3; $i++) {
|
||||||
|
$articleTitleDOMElement = $articleLinkDOMElement->find('.typo-card-title-' . $i, 0);
|
||||||
|
if (!$articleTitleDOMElement instanceof \simple_html_dom_node) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$articleTitle .= $articleTitleDOMElement->innertext;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$articleFullURI = urljoin('https://www.' . $this->getInput('newspaper') . '/', $articleURI);
|
||||||
$item = [
|
$item = [
|
||||||
'title' => $articleTitle,
|
'title' => $articleTitle,
|
||||||
'uri' => $articleFullURI,
|
'uri' => $articleFullURI,
|
||||||
@ -184,7 +182,7 @@ class CentreFranceBridge extends BridgeAbstract
|
|||||||
|
|
||||||
$articleTags = $html->find('#content>div.flex+div.grid section>.bg-gray-light>a.border-gray-dark');
|
$articleTags = $html->find('#content>div.flex+div.grid section>.bg-gray-light>a.border-gray-dark');
|
||||||
if (is_array($articleTags)) {
|
if (is_array($articleTags)) {
|
||||||
$item['categories'] = array_map(static fn ($articleTag) => $articleTag->innertext, $articleTags);
|
$item['categories'] = array_map(static fn ($articleTag) => html_entity_decode($articleTag->innertext), $articleTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
$explode = explode('_', $uri);
|
$explode = explode('_', $uri);
|
||||||
@ -195,6 +193,10 @@ class CentreFranceBridge extends BridgeAbstract
|
|||||||
$item['uid'] = $uid;
|
$item['uid'] = $uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($item['content'])) {
|
||||||
|
$item['content'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
// If the article is a "grand format", we use another parsing strategy
|
// If the article is a "grand format", we use another parsing strategy
|
||||||
if ($item['content'] === '' && $html->find('article') !== []) {
|
if ($item['content'] === '' && $html->find('article') !== []) {
|
||||||
$articleContent = $html->find('article > section');
|
$articleContent = $html->find('article > section');
|
||||||
|
Loading…
Reference in New Issue
Block a user