from pynput.mouse import Button, Controller
def start_requests(self):
try:
self.browser.maximize_window()
except Exception as e:
pass
self.browser.get("https://www.zhipin.com/job_detail")
while not self.check_login():
time.sleep(2)
self.browser.get('https://login.zhipin.com/')
time.sleep(2)
mouse = Controller()
mouse.position = (930, 637)
mouse.press(Button.left)
left = 320
track = []
# 当前位移
current = 0
# 减速阈值
mid = left * 3 / 4
# 间隔时间
t = 0.2
v = 5
while current < left:
if current < mid:
a = random.randint(1, 5)
else:
a = -random.randint(2, 6)
v0 = v
# 当前速度
v = v0 + a * t
# 移动距离
move = v0 * t + 1 / 2 * a * t * t
# 当前位移
current += move
track.append(round(move))
for x in track:
mouse.move(x, random.randint(-1, 1))
time.sleep(0.01)
time.sleep(1)
mouse.release(Button.left)
self.browser.find_element_by_css_selector('form[action="/wapi/zppassport/login/account"] .ipt.ipt-phone').send_keys('')
time.sleep(2)
self.browser.find_element_by_css_selector('form[action="/wapi/zppassport/login/account"] .ipt.ipt-pwd').send_keys('')
time.sleep(3)
self.browser.find_element_by_css_selector('form[action="/wapi/zppassport/login/account"] .form-btn button').click()
time.sleep(2)
if self.check_login():
break