python模拟登录网站_利用python破解js加密模拟登录猎X网

[Python] 纯文本查看 复制代码import re

import os

import time

from selenium import webdriver

from selenium.webdriver import ActionChains

from selenium.webdriver import ChromeOptions

# from exe_js import js1, js2, js3, js4, js5

class OnePlusSpider(object):

def __init__(self):

self.login_url = 'https://account.oneplus.com/cn/login?jump=https%3A%2F%2Faccount.oneplus.com%2Fcn'

self.username = '*****' # 账户名

self.password = '*****' # 密码

# option = ChromeOptions()

# option.add_experimental_option('excludeSwitches', ['enable-automation'])

self.driver = webdriver.Chrome()

self.driver.maximize_window()

# def __del__(self):

# self.driver.close()

@staticmethod

def get_track(distance):

"""

根据偏移量获取移动轨迹

:param distance: 偏移量

:return: 移动轨迹

"""

# 移动轨迹

track = []

# 当前位移

current = 0

# 减速阈值

mid = distance * 4 / 5

# 计算间隔

t = 0.2

# 初速度

v = 0

while current < distance:

if current < mid:

# 加速度为正2

a = 2

else:

# 加速度为负3

a = -3

# 初速度v0

v0 = v

# 当前速度v = v0 + at

v = v0 + a * t

# 移动距离x = v0t + 1/2 * a * t^2

move = v0 * t + 1 / 2 * a * t * t

# 当前位移

current += move

# 加入轨迹

track.append(round(move))

print(track)

print(sum(track))

return track

def one_plus_login(self):

self.driver.get(self.login_url)

self.driver.find_element_by_xpath('//*[@id="input-email"]').send_keys(self.username)

self.driver.find_element_by_xpath('//*[@id="login-password"]').send_keys(self.password)

bnt = self.driver.find_element_by_xpath('//*[@id="nc_1_n1z"]')

ActionChains(self.driver).click_and_hold(bnt).perform()

for x in self.get_track(268):

ActionChains(self.driver).move_by_offset(xoffset=x, yoffset=0).perform()

ActionChains(self.driver).release().perform()

time.sleep(5)

if __name__ == '__main__':

new_spider = OnePlusSpider()

new_spider.one_plus_login()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值