Skip to content

Instantly share code, notes, and snippets.

@Xarrow
Created December 12, 2018 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xarrow/1902cc4bfb4611e8331b5b972e689779 to your computer and use it in GitHub Desktop.
Save Xarrow/1902cc4bfb4611e8331b5b972e689779 to your computer and use it in GitHub Desktop.
# -*- coding:utf-8 -*-
"""
Verion: 1.0
Since : 3.6
Author: zhangjian
Site: https://iliangqunru.bitcron.com/
File: csdaf
Time: 2018/12/12
Add New Functional csdaf
"""
import logging
import sys
import os
import time
import requests
from subprocess import Popen
level = logging.DEBUG
format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
datefmt = '%Y-%m-%d %H:%M'
logging.basicConfig(level=level, format=format, datefmt=datefmt)
logger = logging.getLogger(__name__)
PY3 = False
if sys.version > '3':
PY3 = True
class ADA(object):
def __init__(self):
# declare global session
self.session = requests.session()
self.cookies = {}
self.url = "http://www.kooyuns.com/zkau;jsessionid=2ACDB3B33ED42BCE4271A5BB9986F17A"
# construct headers
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
'Host': 'www.kooyuns.com',
'Origin': 'http://www.kooyuns.com',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
}
def getCaptcha(self):
timsstamp = str(int(time.time() * 1000))
captcha_URL = 'http://www.kooyuns.com/imgcode?random=' + timsstamp
captcha = self.session.get(url=captcha_URL, headers=self.headers)
if not os.path.exists("captcha"):
os.mkdir("captcha")
# save captcha
# @sys.path[0]
try:
with open("captcha\\" + timsstamp + '.gif', 'wb') as f:
f.write(captcha.content)
f.flush()
Popen(sys.path[0] + "\\captcha\\" + timsstamp + '.gif', shell=True)
except:
raise Exception('[!]Captha get failed,error from method of getCaptcha().')
return str(input("[+]input captcha:"))
def login(self):
captcha = self.getCaptcha()
data = {"dtid": "z_8xq",
"cmd_0": "onSubmitForm",
"uuid_0": "sPGP0",
"data_0": {
"": "{\"loginid\":\"nieli\",\"password\":\"hourushi3.0\",\"yzm\":\"" + captcha + "\",\"isSave\":\"false\",\"isAgree\":\"true\"}"}}
res = self.session.post(url=self.url, data=data, headers=self.headers)
print(res.text)
self.cookies = self.session.cookies.get_dict()
index = self.session.get(url='http://www.kooyuns.com/main.zul', headers=self.headers, cookies=self.cookies)
print(index.text)
if __name__ == '__main__':
a = ADA()
a.login()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment