Skip to content

Instantly share code, notes, and snippets.

@slapslash
Last active January 20, 2022 11:43
Show Gist options
  • Save slapslash/d95483b5f3e6d20aaae528828025f990 to your computer and use it in GitHub Desktop.
Save slapslash/d95483b5f3e6d20aaae528828025f990 to your computer and use it in GitHub Desktop.
Get a random selection from the top 5000 PyPI packages and show a short summary of them.
import random
import requests
# will be updated monthly.
top_url = "https://hugovk.github.io/top-pypi-packages/top-pypi-packages-30-days.min.json"
data = requests.get(top_url).json()
packs = [d["project"] for d in data["rows"]]
for _ in range(3):
random_pack = random.choice(packs)
pypi_url = "https://pypi.org/pypi/{}/json".format(random_pack)
p = requests.get(pypi_url).json()
print(random_pack + ":", p["info"]["summary"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment