|
|
@@ -48,7 +48,14 @@ export default class ScraperArticles {
|
|
|
|
|
|
private getLink(article: AnyNode): string {
|
|
|
const selector = this._options.linkSelector ?? "";
|
|
|
- const url = selector !== "" ? this.getProperty(article, selector, Props.LINK) : this._options.url
|
|
|
+ let url = selector !== "" ? this.getProperty(article, selector, Props.LINK) : this._options.url
|
|
|
+
|
|
|
+ // Fallback: when the article itself is wrapped by an anchor (e.g. BioBioChile)
|
|
|
+ // and the configured linkSelector does not find a descendant link.
|
|
|
+ if (!url && selector !== "") {
|
|
|
+ const $ = load(article);
|
|
|
+ url = $(article).closest("a").attr("href") ?? "";
|
|
|
+ }
|
|
|
|
|
|
return !this.isValidUrl(url) && this._options.linkPrefix !== undefined
|
|
|
? (this._options.linkPrefix + url.trim()).trim()
|