python pyppeteer 破解京東滑塊功能的代碼
Pyppeteer簡介
介紹Pyppeteer之前先說一下Puppeteer,Puppeteer是谷歌出品的一款基于Node.js開發(fā)的一款工具,主要是用來操縱Chrome瀏覽器的 API,通過Javascript代碼來操縱Chrome瀏覽器,完成數(shù)據(jù)爬取、Web程序自動測試等任務(wù)。
在上篇文章給大家詳細介紹了python爬蟲 Pyppeteer使用方法解析 ,感興趣的朋友可以點擊查看。
今天給大家介紹python pyppeteer 破解京東滑塊功能,具體代碼如下所示:
import asyncio import random import cv2 from pyppeteer import launch from urllib import request # 滑塊的缺口距離識別 async def get_distance(): img = cv2.imread('image.png', 0) template = cv2.imread('template.png', 0) res = cv2.matchTemplate(img, template, cv2.TM_CCORR_NORMED) value = cv2.minMaxLoc(res)[2][0] distance = value * 278/360 return distance async def main(): browser = await launch({ 'headless': False,# 需要設(shè)置一個路徑 'userDataDir': r'E:\mj', 'args': ['--no-sandbox', '--window-size=1366,768'], }) page = await browser.newPage() await page.setViewport({'width': 1366, 'height': 768}) await page.goto('https://passport.jd.com/login.aspx') await page.waitFor(1000) await page.click('div.login-tab-r') await page.waitFor(1000) # TODO 模擬人工輸入用戶名、密碼 輸入自己的賬號密碼 await page.type('#loginname', 'yazhishaw', {'delay': random.randint(60, 121)}) await page.type('#nloginpwd', '123456', {'delay': random.randint(100, 151)}) await page.waitFor(2000) await page.click('div.login-btn') await page.waitFor(3000) # 模擬人工拖動滑塊、失敗則重試 while True: if await page.J('#ttbar-login'): print('登錄成功!') await page.waitFor(6000) break else: image_src = await page.Jeval('.JDJRV-bigimg >img', 'el => el.src') request.urlretrieve(image_src, 'image.png') template_src = await page.Jeval('.JDJRV-smallimg >img', 'el => el.src') request.urlretrieve(template_src, 'template.png') await page.waitFor(3000) el = await page.J('div.JDJRV-slide-btn') box = await el.boundingBox() await page.hover('div.JDJRV-slide-btn') distance = await get_distance() await page.mouse.down() await page.mouse.move(box['x'] + distance + random.uniform(30, 33), box['y'], {'steps': 20}) await page.waitFor(random.randint(300, 700)) await page.mouse.move(box['x'] + distance + 29, box['y'], {'steps': 20}) await page.mouse.up() await page.waitFor(3000) asyncio.get_event_loop().run_until_complete(main())
到此這篇關(guān)于python pyppeteer 破解京東滑塊功能的代碼的文章就介紹到這了,更多相關(guān)python pyppeteer 京東滑塊內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用Python3+PyQT5+Pyserial 實現(xiàn)簡單的串口工具方法
今天小編就為大家分享一篇使用Python3+PyQT5+Pyserial 實現(xiàn)簡單的串口工具方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-02-02python使用pandas庫導(dǎo)入并保存excel、csv格式文件數(shù)據(jù)
CSV格式文件很方便各種工具之間傳遞數(shù)據(jù),平時工作過程之中會將數(shù)據(jù)保存為CSV格式,這篇文章主要介紹了python使用pandas庫導(dǎo)入并保存excel、csv格式文件數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2017-12-12python使用Celery構(gòu)建異步任務(wù)隊列提高服務(wù)器吞吐量及響應(yīng)速度
這篇文章主要介紹了python使用Celery構(gòu)建異步任務(wù)隊列提高服務(wù)器吞吐量及響應(yīng)速度實例探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01pycharm中keras導(dǎo)入報錯無法自動補全cannot?find?reference分析
這篇文章主要介紹了pycharm中keras導(dǎo)入報錯無法自動補全cannot?find?reference分析,文章圍繞主題展開分析,需要的小伙伴可以參考一下2022-07-07numpy多項式擬合函數(shù)polyfit的使用方法代碼
這篇文章主要給大家介紹了關(guān)于numpy多項式擬合函數(shù)polyfit的使用方法,np.polyfit是Numpy庫中的一個函數(shù),用于在最小二乘意義下擬合多項式曲線到數(shù)據(jù)點集,需要的朋友可以參考下2024-01-01