Skip to content

Instantly share code, notes, and snippets.

@0xdeepmehta
Created August 14, 2020 10:32
Show Gist options
  • Save 0xdeepmehta/222498b5f1fbe0d967847bbaaf32a2aa to your computer and use it in GitHub Desktop.
Save 0xdeepmehta/222498b5f1fbe0d967847bbaaf32a2aa to your computer and use it in GitHub Desktop.
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())
@vivekascoder
Copy link

vivekascoder commented Aug 14, 2020

import pickle
file_content = open("filename", "rb").read()
data = pickle.load(file_content)
print(data)

data is list

@vivekascoder
Copy link

vivekascoder commented Aug 14, 2020

import pickle

pickle.dump([12, ...], open("file-name", "wb"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment