mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-25 02:46:15 +03:00
[CssSelectorBridge] Handling of missing links (#3585)
When using parent element as URL selector: * If no <a> inside some elements, ignore them * If no <a> inside ALL elements, report an error Fixes #3573 #issuecomment-1656943318
This commit is contained in:
parent
f957eea300
commit
f8fd05f08f
1 changed files with 7 additions and 0 deletions
|
@ -198,6 +198,9 @@ class CssSelectorBridge extends BridgeAbstract
|
|||
}
|
||||
if ($link->tag != 'a') {
|
||||
$link = $link->find('a', 0);
|
||||
if (is_null($link)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$item['uri'] = $link->href;
|
||||
$item['title'] = $link->plaintext;
|
||||
|
@ -209,6 +212,10 @@ class CssSelectorBridge extends BridgeAbstract
|
|||
$link_to_item[$link->href] = $item;
|
||||
}
|
||||
|
||||
if (empty($link_to_item)) {
|
||||
returnClientError('The provided URL selector matches some elements, but they do not contain links.');
|
||||
}
|
||||
|
||||
$links = $this->filterUrlList(array_keys($link_to_item), $url_pattern, $limit);
|
||||
|
||||
if (empty($links)) {
|
||||
|
|
Loading…
Reference in a new issue