def retrieve_latest_revids(pageids_chunk):
  """Gets the latest revision id for an article."""
  headers = {"Accept": "application/json"}
  params = {
      "action": "query",
      "format": "json",
      "pageids": "|".join(str(x) for x in pageids_chunk),
      "prop": "revisions",
      "rvprop": "ids",
  }
  response = request_helper(ENWIKI_ENDPOINT, headers=headers, params=params)
  response_json = response.json()
  pages = response_json["query"]["pages"]
  output = {}
  for pageid, value in pages.items():
    revisions = value.get("revisions", None)
    if revisions is None:
      continue
    revid = revisions.pop().get("revid", None)
    if revid is not None:
      output[pageid] = revid
  return output
Gets the latest revision id for an article.
language/fruit/scripts/get_topics.py