JSON API for PyPi - how to list packages?

前端 未结 4 2160
后悔当初
后悔当初 2020-12-15 18:33

There is a JSON API for PyPI which allows getting data for packages:

http://pypi.python.org/pypi//json
http://pypi.python.org/pypi/

        
4条回答
  •  旧时难觅i
    2020-12-15 19:14

    I know that you asked for a way to do this from the JSON API, but you can use the XML-RPC api to get this info very easily, without having to parse HTML.

    try:
         import xmlrpclib
    except ImportError:
         import xmlrpc.client as xmlrpclib
    
    client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
    # get a list of package names
    packages = client.list_packages()
    

提交回复
热议问题