Create download-keyserv.py

This commit is contained in:
yakamok 2018-05-28 22:40:13 +02:00 committed by GitHub
parent 7051c5c869
commit ecd9c3b7b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

28
download-keyserv.py Normal file
View File

@ -0,0 +1,28 @@
import requests
from bs4 import BeautifulSoup
import urllib2
import base64
import sys
try:
if "http://" not in sys.argv[1]:
print "not the expected url please check your input"
else:
url = sys.argv[1]
file_name = url[url.index("@"):url.index("&")].replace('@','')
print file_name
r = requests.get(url)
data = r.text
data_cleaned = {}
for x in data.split():
if 'class="uid"' in x and "@" in x:
data_cleaned[int(x.replace('&#x2F;','/').replace('class="uid">','').replace('</span>','').split('@')[0])] = x.replace('&#x2F;','/').replace('class="uid">','').replace('</span>','').split('@')[1]
with open(file_name,"wb") as handle:
for x in range(0,len(data_cleaned)):
handle.write(base64.b64decode(data_cleaned[x]))
print file_name + " has been downloaded."
except:
print "Something went wrong please try again, check your input or try switching your computer on and off"