Reputation:
pip list --format=columns |wc -l
73
It shows that 73 packages installed on my local pc.
How to get total number of packages in pypi remote official server?
Upvotes: 2
Views: 1247
Reputation: 1047
What about parsing PyPI's official webpage? If you'd like to do so, we can use requests
package to get the content of the page and extract the content we want using BeautifulSoup
package from the page like this.
This is the content that are extracting. We'll need to install requests
and beautifulsoup4
packages if you haven't already.
pip install requests
pip install beautifulsoup4
Request and parse:
import requests
from bs4 import BeautifulSoup
response = requests.get("https://pypi.python.org/pypi")
soup = BeautifulSoup(response.content, 'html.parser')
print(soup.select('div.section > p > strong')[0].get_text())
Upvotes: 3