sparqlwikipediawikidatawikidata-apiwikidata-query-service

How to get IMDb links of all films in a category page on Wikipedia?


I want to get the IMDb links of all films in a category page on Wikipedia, for example: https://en.wikipedia.org/wiki/Category:American_historical_films. I have heard of Wikidata Query Service and PetScan but honestly they are too complicated for me to learn at the moment. Could you please help me how to request the IMDb links using these tools? Thanks in advance.


Solution

  • Here is the Wikidata query code

    SELECT ?item ?title ?imdb WHERE {
      {
       SELECT ?item ?title WHERE {
           SERVICE wikibase:mwapi {
              bd:serviceParam wikibase:api "Generator".
              bd:serviceParam wikibase:endpoint "en.wikipedia.org".
              bd:serviceParam mwapi:generator "categorymembers".
              bd:serviceParam mwapi:gcmtitle "category:American_historical_films";
                         mwapi:gcmprop "ids|title";
                         mwapi:gcmtype "page";
                         mwapi:gcmlimit "max".
              ?title wikibase:apiOutput mwapi:title .
              ?item wikibase:apiOutputItem mwapi:item.
          }
       }LIMIT 100 
      }
      ?item wdt:P345 ?imdb.
    } LIMIT 100
    

    Wikidata query URL with result limited to 100