Created
July 7, 2012 21:42
-
-
Save srounet/3068164 to your computer and use it in GitHub Desktop.
Download last HideMyAss proxylist
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
#!/usr/bin/env python | |
import email, getpass, imaplib, os | |
from datetime import date | |
username = 'YOUR_USERNAME' #Ex: [email protected] | |
#XXX: base64 decode could be nice | |
password = 'YOUR_PASSWORD' | |
imap_server = 'YOUR_IMAP_SERVER' #Ex: imap.gmail.com | |
download_path = '/home/YOUR_HOME/proxy_list' | |
m = imaplib.IMAP4_SSL(imap_server) | |
m.login(username, password) | |
m.select("[Gmail]/All Mail") #XXX Change this to your imap box | |
resp, items = m.search(None, "(SUBJECT \"ProxyList for Today\")") | |
for emailid in items[0].split(): | |
resp, data = m.fetch(emailid, "(RFC822)") | |
text = data[0][1] | |
msg = email.message_from_string(text) | |
for part in msg.walk(): | |
if part.get_content_maintype() == 'multipart': | |
continue | |
if not part.get('Content-Disposition'): | |
continue | |
filename = part.get_filename() | |
if not date.today().strftime('%m-%d-%y') in filename: | |
continue | |
data = part.get_payload(decode=True) | |
if not data: | |
continue | |
path = os.path.abspath(download_path) | |
if not os.path.exists(path): | |
os.makedirs(path) | |
filepath = os.path.join(path, filename) | |
with open(filepath, 'w') as fd: | |
fd.write(data) | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment