boss直聘滑动验证码问题
来源:12-5 计算滑动轨迹
weixin_慕用3052561
2020-03-20
老师您好,我这几天爬取boss直聘网,遇到这种验证码,以为很简单,但实际怎么也验证不了,这种怎么搞
写回答
1回答
-
weixin_慕用3052561
提问者
2020-03-21
已解决这个问题了,要用python控制鼠标点击,还有登录之前要先滑动验证,再输入和登录,这样就能成功
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
052020-04-10
相似问题