Skip to content

Commit 1c12a33

Browse files
committed
Use GraphQL to fetch paginated keywords
1 parent c622579 commit 1c12a33

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/Imdb/Title.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,9 +2955,17 @@ public function officialSites()
29552955
public function keywords_all()
29562956
{
29572957
if (empty($this->all_keywords)) {
2958-
$page = $this->getPage("Keywords");
2959-
if (preg_match_all('|<a.*?href="/search/keyword[^>]+?>(.*?)</a>|', $page, $matches)) {
2960-
$this->all_keywords = $matches[1];
2958+
$query = <<<EOF
2959+
keyword {
2960+
text {
2961+
text
2962+
}
2963+
}
2964+
EOF;
2965+
$edges = $this->graphQlGetAll("TitleKeywordsPagination", "keywords", $query);
2966+
2967+
foreach ($edges as $edge) {
2968+
$this->all_keywords[] = $edge->node->keyword->text->text;
29612969
}
29622970
}
29632971
return $this->all_keywords;

0 commit comments

Comments
 (0)