Created
August 14, 2020 10:32
-
-
Save 0xdeepmehta/222498b5f1fbe0d967847bbaaf32a2aa to your computer and use it in GitHub Desktop.
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
from requests_html import HTMLSession | |
from bs4 import BeautifulSoup | |
session = HTMLSession() | |
all_git_ignore = [] | |
def _fetchAllModuleData(): | |
r = session.get("https://github.com/github/gitignore/") | |
soup = BeautifulSoup(r.content,'lxml') | |
links = soup.find_all('a') | |
for i in links: | |
if '.gitignore' in i.attrs['href']: | |
module = i.attrs['href'].replace('blob/','') | |
final_module_url = f'https://raw.githubusercontent.com{module}' | |
all_git_ignore.append(final_module_url) | |
def createModuleGitignore(moduleInput): | |
moduleInput = moduleInput.lower() | |
download_module_url = '' | |
for module in all_git_ignore: | |
if moduleInput in module[58:-10].lower(): | |
print(module[58:-10]) | |
download_module_url = module | |
print(module) | |
data = session.get(download_module_url) | |
open(f'{download_module_url[58:]}', 'w').write(data.content.decode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import pickle
pickle.dump([12, ...], open("file-name", "wb"))