Due to unfortunete amont of traffic, team python.org decided to disable xmlrpc endpoint, incident report being update here: https://status.python.org/incidents/grk0k7sz6zkp
Also an issue tracking on github: pypa/pip#9292
The error message:
This API has been temporarily disabled due to unmanageable load and will be deprecated in the near future. Please use the Simple or JSON API instead.
So I made a simple script to query from the web page directly (only first page of the result.
requires: $ pip install beautifulsoup4
#!/usr/bin/env python3
import sys, requests, textwrap
from bs4 import BeautifulSoup
if (len(sys.argv) < 2):
raise ValueError("there must be at least 1 keyword")
sorting = [ '', '-ceated', '-zscore' ]
keywords = "+".join(sys.argv[1:])
URL = f'https://pypi.org/search/?q={keywords}&o={sorting[0]}'
page = requests.get(URL)
page.raise_for_status()
soup = BeautifulSoup(page.text, 'html.parser')
def tag_colander(tag):
return tag.get_text()
names = list(map(tag_colander, soup.find_all('span',
class_='package-snippet__name')))
descs = list(map(tag_colander, soup.find_all('p',
class_='package-snippet__description')))
width = len(max(names, key=len))
for n, d in zip(names, descs):
print(n.ljust(width,' '), '-',
textwrap.fill(d, 64).replace('\n', '\n' + ' ' * (width+3) ))
print('More results please visit: ', URL+'&page=2')