Exemple #1
0
def spiders(zhanghao,mima):
    try:
        ses=requests.session()
        headers = {
            "Accept-Encoding":"gzip, deflate, br",
            "Accept-Language":"zh-CN,zh;q=0.9",
            "Cache-Control":"no-cache",
            "Connection":"keep-alive",
            "Content-Length":"24",
            "Content-Type":"application/json; charset=UTF-8",
            "Host":"www.tianyancha.com",
            "Origin":"https://www.tianyancha.com",
            "Pragma":"no-cache",
            "Referer":"https://www.tianyancha.com/",
            "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36",
            "X-Requested-With":"XMLHttpRequest",
        }
        url='https://www.tianyancha.com/verify/geetest.xhtml'
        data = {"uuid":"1592968082445"}
        res=ses.post(url,headers=headers,json=data,timeout=15)
        json_res=json.loads(res.text)
        gt=json_res["data"]["gt"]
        challenge1=json_res["data"]["challenge"]
        challenge, gt, c, s, distance, track=get_track(challenge1,gt,ses)
        result=run(challenge, gt, c, s, distance, track)
        challenge1 = result["challenge"]
        validate = result["validate"]
        print(result)
        data1  ={"mobile":"{}".format(zhanghao),"cdpassword":"******".format(md5(mima)),"loginway":"PL","autoLogin":False,"challenge":"{}".format(challenge1),"validate":"{}".format(validate),"seccode":"{}|jordan".format(validate)}
        login = ses.post(url="https://www.tianyancha.com/cd/login.json",json=data1,headers=headers,timeout=15)
        print(login.text)
    except Exception as e:
        print(e)
Exemple #2
0
def main():
    headers = {
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KtmL, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
    }
    #获取id值部分
    with open('id.js', 'r', encoding='utf-8') as f:
        content = f.read()
    ctx = execjs.compile(content)
    url = ctx.call('pp')
    r = requests.get(url, headers=headers)
    id_val = r.text.split(':')[1].split('}')[0]

    #获取验证码图片部分
    tokens = id_val.split('|')[1]
    arg_list = ctx.call('pp', tokens)
    with open('imgs.js', 'r', encoding='utf-8') as f:
        content = f.read()
    ctx = execjs.compile(content)
    tm = int(time.time()) * 1000
    p_val = ctx.call('get_p', arg_list[0], arg_list[1], 1, tm, '', '', '')
    params = {'p1': p_val['p1'], 'p2': p_val['p2']}
    del p_val['p1']
    del p_val['p2']
    r = requests.post('https://sphinx.tongdun.net/sphinx/validatecode/v1',
                      params=params,
                      data=p_val,
                      headers=headers)
    validateCodeObj = r.json()["validateCodeObj"]
    slideBgi = validateCodeObj['slideBgi']
    slideImage = validateCodeObj['slideImage']
    request.urlretrieve('https://static.tongdun.net' + slideBgi, '2.jpeg')
    request.urlretrieve('https://static.tongdun.net' + slideImage, '1.png')
    with open('pincuo.js', 'r', encoding='utf-8') as f:
        content = f.read()
    ctx2 = execjs.compile(content)
    bg = ctx2.call('distance', validateCodeObj['bgImageSplitSequence'],
                   validateCodeObj['imageGeneral'])
    img_recv(bg)
    distance = get_distance()
    track = get_track(distance)
    sec_p_val = ctx.call('get_p', arg_list[0], arg_list[1], 3, tm, track,
                         validateCodeObj, distance)
    params2 = {'p1': sec_p_val['p1'], 'p2': sec_p_val['p2']}
    del sec_p_val['p1']
    del sec_p_val['p2']
    rr = requests.post('https://sphinx.tongdun.net/sphinx/validatecode/v1',
                       params=params2,
                       data=sec_p_val,
                       headers=headers)
    if rr.json().get("validateToken"):
        print(rr.json()["validateToken"])
    else:
        print('未通过')
Exemple #3
0
    def get_check_w(self):
        url = "http://127.0.0.1:8090/get_check_w"

        data = {
            "gt": self.gt,
            "challenge": self.challenge,
            "config": self.type_config,
            "s": self.params_s,
            "tracks": json.dumps(get_track([(140, 595), (436, 630)]))
        }

        res = requests.post(url, data=data)
        if res.status_code == 200:
            logging.info("请求点击验证的w参数成功")
            self.check_w = res.text
        else:
            logging.error("请求点击验证的w参数失败")
Exemple #4
0
    return miles, time


trackselection = int(
    input('Select a track between 1 and {} => '.format(
        track.get_number_of_tracks())))
print(trackselection)
curvespd = input('Speed on curved segments (MPH) => ')
print(curvespd)
curvespd = float(curvespd)
straightspd = input('Speed on straight segments (MPH) => ')
print(straightspd)
straightspd = float(straightspd)
print('')

print('Track:', track.get_track(int(trackselection)), sep='\n', end='\n')

curvetuple = calculate_curve(track.get_track(trackselection), curvespd)
straighttuple = calculate_straight(track.get_track(trackselection),
                                   straightspd)

curvepercent = (curvetuple[0] / (curvetuple[0] + straighttuple[0]))
straightpercent = (straighttuple[0] / (curvetuple[0] + straighttuple[0]))

if curvetuple[0] == 0:
    agspeed = straightspd
elif straighttuple[0] == 0:
    agspeed = curvespd
else:
    #agspeed = (curvetuple[0] + straighttuple[0]) / ((curvetuple[0] / curvetuple[1]) + (straighttuple[0] / straighttuple[1]))
    agspeed = 1 / ((((1 / curvespd)) * curvepercent) +
Exemple #5
0
tak = int(input("Select a track between 1 and 5 => "))  #ask for track number
print(tak)

speed_curve = input("Speed on curved segments (MPH) => ")  #speed for curves
print(speed_curve)
speed_curve = float(speed_curve)

speed_straight = input(
    "Speed on straight segments (MPH) => ")  #speed for straights
print(speed_straight)
speed_straight = float(speed_straight)

print()

print("Track:")
print(track.get_track(tak))  #prints track

length_curve, time_curve = calculate_curve(
    tak, speed_curve)  #finds total length and time for curves
length_straight, time_straight = calculate_straight(
    tak, speed_straight)  #finds total length and time for straights

length_total = length_curve + length_straight  #finds total length

time_total = round(((time_curve + time_straight) * 3600),
                   2)  #finds total time spent

speed_average = length_total / (time_curve + time_straight
                                )  #finds average speed

print("is {:.2f}".format(length_total),
Exemple #6
0
    # 找到移动按钮,找不到就跳出
    try:
        pic=chrome.find_element_by_xpath(
            '//div[@class="geetest_slider_button"]'
        )
        # if num>0:
        #     ref = chrome.find_element_by_xpath(
        #         '//a[@class="geetest_refresh_1"]'
        #     )
        #     webdriver.ActionChains(chrome).click(ref).perform()
    except:
        break
    sleep(2)
    # 截屏
    chrome.save_screenshot('screenshot.png')
    sleep(2)
    # 计算距离
    offset=pil.m()
    # 模拟轨迹,还是有问题,可以看到距离没问题,轨迹一直有问题
    newtrack=track.get_track(offset)
    webdriver.ActionChains(chrome).click_and_hold(pic).perform()
    for x in newtrack:
        webdriver.ActionChains(chrome).move_by_offset(xoffset=x,yoffset=random.randint(-5,5)).perform()
    sleep(0.5)
    # webdriver.ActionChains(chrome).move_by_offset(xoffset=offset, yoffset=0).perform()
    webdriver.ActionChains(chrome).release().perform()
    sleep(3)
    num+=1
sleep(5)
print()
Exemple #7
0
def main(actoken=None):
    headers = {
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-CN,zh;q=0.9',
        'Cache-Control': 'no-cache',
        'Host': 'c.dun.163yun.com',
        'Referer': 'https://dun.163.com/trial/jigsaw',
        'Pragma': 'no-cache',
        'Proxy-Connection': 'keep-alive',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.'
                      '3904.108 Safari/537.36'
    }
    with open('mm.js', 'r', encoding='utf-8')as f:
        content = f.read()
    ctx = execjs.compile(content)
    fp = ctx.call('get_fp')
    callback = ctx.call('get_callback')
    with open('tnp.js', 'r')as f:
        content = f.read()
    ctx = execjs.compile(content)
    cb = ctx.call('cb')
    data = {
        "id": "07e2387ab53a4d6f930b8d9a9be71bdf",
        "fp": fp,
        "https": "true",
        "type": "2",
        "version": "2.14.1",
        "dpr": "1",
        "dev": "1",
        "cb": cb,
        "ipv6": "false",
        "runEnv": "10",
        "group": "",
        "scene": "",
        "width": "320",
        "token": "",
        "referer": "https://dun.163.com/trial/jigsaw",
        "callback": callback
    }
    r = requests.get('https://c.dun.163.com/api/v2/get', params=data, headers=headers)
    data_ = json.loads(re.findall('.*?\((.*?)\);', r.text)[0])
    token = data_['data']['token']
    request.urlretrieve(data_['data']['front'][0], 'img/1.png')
    request.urlretrieve(data_['data']['bg'][0], 'img/2.jpg')
    distance = get_gap() + 5
    trace = get_track(distance)
    left = trace[-1][0] - 10
    data_ = ctx.call('get_data', token, trace, left)
    cb = ctx.call('cb')

    # 下面actoken生成部分
    with open('yidun.js', 'r', encoding='utf-8')as f:
        content = f.read()
    ctx = execjs.compile(content)
    rdtm = ctx.call('rdtm')
    did = get_actoken_median(ctx, rdtm)
    if not actoken:
        actoken = ctx.call('actoken', rdtm, did)

    # 提交验证部分
    get_data = {
        "id": "07e2387ab53a4d6f930b8d9a9be71bdf",
        "token": token,
        "acToken": actoken,
        "data": data_,
        "width": "320",
        "type": "2",
        "version": "2.14.1",
        "cb": cb,
        "extraData": "",
        "runEnv": "10",
        "referer": "https://dun.163.com/trial/jigsaw",
        "callback": "__JSONP_48mk47t_1"
    }
    r = requests.get('https://c.dun.163.com/api/v2/check', headers=headers, params=get_data)

    global counter
    if counter == 1:
        print(r.text)
    else:
        counter += 1
        main(actoken)
Exemple #8
0
#Take user's input  
track_num=input("Select a track between 1 and {} => ".format(track_range))
print(track_num)
speed_curve=input("Speed on curved segments (MPH) => ")
print(speed_curve)
speed_straight=input("Speed on straight segments (MPH) => ")
print(speed_straight)

#Convert to right unit
speed_curve = float(speed_curve)
speed_straight = float(speed_straight)
track_num = int(track_num)

#Use function from track.py
track = track.get_track(track_num)

#caculate length of each track
track_lower = track.lower()

#use writen functions to caculate distance and time
curve_track = calculate_curve(track_lower, speed_curve)
straight_track = calculate_straight(track_lower, speed_straight)

#calculate total length and time, and average speed
total_length=curve_track[0]+straight_track[0]
total_time=curve_track[1]+straight_track[1]
total_time_second=total_time*3600
avg_speed = total_length/total_time

#output result based on avg speed