Last active
May 9, 2020 16:53
-
-
Save derek-adair/abd5f8bbb36af773c58423109cd9675c to your computer and use it in GitHub Desktop.
Python script to show how many dependencies each package has
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
import requests | |
import json | |
import lxml.html | |
from lxml.cssselect import CSSSelector | |
f = open('package.json') | |
packageJson = json.load(f) | |
for dep in packageJson['dependencies']: | |
response = requests.get('https://www.npmjs.com/package/{}?activeTab=dependencies'.format(dep)) tree = lxml.html.fromstring(response.text) sel = CSSSelector('#dependencies h2:first-child') results = sel(tree) print ("{} has....".format(dep)) | |
print (lxml.html.tostring(results[0])) | |
print ("----------------------------------------") |
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
requests | |
lxml | |
cssselect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment