pip list --format=columns |wc -l
73
它显示我的本地pc上安装了73个软件包。
如何获取pypi远程官方服务器的套餐总数?
发布于 2017-11-25 16:34:48
解析PyPI's official webpage怎么样?如果你想这样做,我们可以使用requests
包来获取页面的内容,并使用BeautifulSoup
包从页面中提取我们想要的内容,如下所示。
这是正在提取的the content。如果您尚未安装requests
和beautifulsoup4
包,则需要安装它们。
pip install requests
pip install beautifulsoup4
请求和解析:
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())
https://stackoverflow.com/questions/47481776
复制相似问题