diff --git a/bridges/PokemonNewsBridge.php b/bridges/PokemonNewsBridge.php new file mode 100644 index 00000000..954e584c --- /dev/null +++ b/bridges/PokemonNewsBridge.php @@ -0,0 +1,44 @@ +find('.news-list ul li') as $item) { + $title = $item->find('h3', 0)->plaintext; + $description = $item->find('p.hidden-mobile', 0); + $dateString = $item->find('p.date', 0)->plaintext; + // e.g. September 15, 2022 + $createdAt = date_create_from_format('F d, Y', $dateString); + // todo: + $tagsString = $item->find('p.tags', 0)->plaintext; + $path = $item->find('a', 0)->href; + $imagePath = $item->find('img', 0)->src; + $tags = explode('&', $tagsString); + $tags = array_map('trim', $tags); + + $this->items[] = [ + 'title' => $title, + 'uri' => sprintf('https://www.pokemon.com%s', $path), + 'timestamp' => $createdAt ? $createdAt->getTimestamp() : time(), + 'categories' => $tags, + 'content' => sprintf( + '

%s', + $imagePath, + $description ? $description->plaintext : '' + ), + ]; + } + } +}