Skip to content

Instantly share code, notes, and snippets.

@Splint3r7
Last active November 1, 2022 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Splint3r7/69e73ac50b809b8618d41729d8bf03e8 to your computer and use it in GitHub Desktop.
Save Splint3r7/69e73ac50b809b8618d41729d8bf03e8 to your computer and use it in GitHub Desktop.
Extract Emails from Npm Packge Names - https://api.npms.io/
import requests
import sys
import json
import concurrent.futures
output_file = open("emails_res.txt", "w")
def Emails(package):
req = requests.get("https://api.npms.io/v2/package/{}".format(package))
resp = json.loads(req.text)
try:
for key, value in resp.items():
if key == "collected":
metadata = value['metadata']
emails = len(metadata['maintainers'])
for email in range(0, emails):
email_obj = metadata['maintainers'][email]
for key, value in email_obj.items():
if "email" in key:
print(value)
output_file.write(str(value)+"\n")
except Exception as e:
print(e)
if __name__ == '__main__':
packages_list = []
packages = open("all_packages_names.txt", "r")
for package in packages:
package = package.strip()
packages_list.append(package)
packages.close()
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
executor.map(Emails, packages_list)
output_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment