Created
December 18, 2020 23:15
-
-
Save eabase/feac16947df00babfe25c1984839eb68 to your computer and use it in GitHub Desktop.
pip search removed - The Return (How hard can it be?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic pip search function provided by: | |
# https://pypi.org/project/pip-search/ | |
import sys | |
from urllib import request | |
from tabulate import tabulate | |
def search () : | |
f = request.urlopen('https://pypi.org/search/?q=%s' % sys.argv[1]) | |
raw_text=str(f.read()) | |
raw_names=raw_text.split('<span class="package-snippet__name">')[1:-2] | |
names=[] | |
for name in raw_names : | |
names.append(name.split('</span>')[0]) | |
raw_desc=raw_text.split('<p class="package-snippet__description">')[1:-2] | |
descs=[] | |
for desc in raw_desc : | |
descs.append(desc.split('</p>')[0]) | |
header=[['Name', 'Description'],['','']] | |
rows=[[names[i],descs[i]] for i in range(len(names))] | |
print(tabulate(header+rows)) | |
if __name__ == '__main__': | |
search() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a more advanced handling, please see: