Created
April 18, 2014 07:52
-
-
Save fffonion/11030280 to your computer and use it in GitHub Desktop.
download K Project everyday wallpaper
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 __future__ import print_function | |
from Crypto.Cipher import AES | |
import os, os.path as opath | |
import binascii | |
import time | |
from datetime import datetime, timedelta | |
from httplib2 import Http | |
pad = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16) | |
unpad = lambda s : s[0:-ord(s[-1])] | |
h2b = lambda x:binascii.unhexlify(x) | |
b2h = lambda x:binascii.hexlify(x) | |
IV = h2b('30303030303030303030303030303030') | |
def make_param(inp): | |
a = AES.new(h2b('e1bb1154909ae7f3fd126ed8c498ab01'), AES.MODE_CBC, IV) | |
return b2h(a.encrypt(pad('date=%s&key=e1bb1154909ae7f3' % inp))) | |
base = 'http://www.365daysxvisuals.com' | |
headers = {'User-Agent' : 'Apache-HttpClient/UNAVAILABLE (java 1.4)', 'Connection' : 'Keep-Alive'} | |
uris = {'c_port' : 'c1', 'c_land' : 'c2', 'g_port' : 'l1', 'g_land' : 'l2'} | |
ht = Http() | |
working_dir = r'Z:/KH' | |
start = datetime(2013, 1, 1, 0, 0) | |
end = datetime.now() | |
oneday = timedelta(hours = 24) | |
while start < end: | |
path = opath.join(working_dir, start.strftime('%Y%m')) | |
if not opath.exists(path): | |
os.makedirs(path) | |
for name in uris: | |
uri = uris[name] | |
fname = opath.join(path, start.strftime('%Y%m%d') + '_' +name + '.jpg') | |
if opath.exists(fname): | |
continue | |
resp, ct = ht.request('%s/cgi-bin/%s_a.cgi?param=%s' % ( | |
base, uri, make_param(start.strftime('%Y%m%d')) | |
) | |
, headers = headers) | |
if int(resp['status']) == 200: | |
with open(fname, 'wb') as f: | |
f.write(ct) | |
print(start.strftime('%y%m%d'), name, 'done.') | |
else: | |
print('!!!!', start.strftime('%y%m%d'), name, 'encounted an error.') | |
#time.sleep(0.5) | |
start += oneday | |
#time.sleep(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment