[PikabuBridge] Skip sponsored posts (#2983)

* [PikabuBridge] Skip sponsored posts

Sponsored posts appear very rarely in html code.
But when they appear, they always have different url that results junk feed.

One of the example is [1]. After visiting it, you will be redirected to [2] that is marked as
"Партнёрский материал" in Russian, or "Sponsored post" in English.

[1] https://pikabu.ru/story/a_mla_posa_m_memu_seyla_otorathche_idomikhlenonoikhmyav_sseyla_otoratazoed__9388770?from=cpm
[2] https://pikabu.ru/story/kakim_dolzhen_byit_vash_noutbuk_9388770

* lint

Co-authored-by: Dag <me@dvikan.no>
This commit is contained in:
Eugene Molotov 2022-08-25 21:09:06 +05:00 committed by GitHub
parent fd0d5350be
commit 43ad54dba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -132,6 +132,10 @@ class PikabuBridge extends BridgeAbstract
} }
$title_element = $post->find('.story__title-link', 0); $title_element = $post->find('.story__title-link', 0);
if (str_contains($title_element->href, 'from=cpm')) {
// skip sponsored posts
continue;
}
$title = $title_element->plaintext; $title = $title_element->plaintext;
$community_link = $post->find('.story__community-link', 0); $community_link = $post->find('.story__community-link', 0);