From 7e6f21ac776ff8b83cf7a540dc5862bd73234e65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 07:53:09 +0000 Subject: [PATCH 1/2] Initial plan From c4ac2605ea4e96954e44219090929b284fbc736f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 07:55:08 +0000 Subject: [PATCH 2/2] Fix HTTP 429 from pypistats.org by adding User-Agent header --- fetch.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fetch.py b/fetch.py index c69caab..50a1559 100644 --- a/fetch.py +++ b/fetch.py @@ -1,7 +1,7 @@ import json from datetime import date from pathlib import Path -from urllib.request import urlopen +from urllib.request import Request, urlopen def _read_archive(path): @@ -49,7 +49,11 @@ def count_conda(package, channel, path): def count_pypi(package, path): """Download count for the PyPI distribution.""" - pypi_api = urlopen(f"https://pypistats.org/api/packages/{package}/overall") + req = Request( + f"https://pypistats.org/api/packages/{package}/overall", + headers={"User-Agent": "fetch-download-stats/1.0"}, + ) + pypi_api = urlopen(req) pypi_json = json.loads(pypi_api.read()) archive = _read_archive(path) for data in pypi_json["data"]: