哔哩哔哩点击验证码

'''

img_code
'''
import random
import time
 
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
 
from 技术提升.工具.chaojiying.chaojiying import get_code
 
url = 'https://passport.bilibili.com/login?from_spm_id=333.851.top_bar.login_window'
driver = webdriver.Chrome()
driver.get(url)
# for i in range(3):
# 输入账号
time.sleep(random.randint(13))
driver.find_element_by_id('login-username').send_keys('18736709382')
# 输入密码
time.sleep(random.randint(13))
driver.find_element_by_id('login-passwd').send_keys('xiuxiu521@')
# 点击登录
time.sleep(random.randint(13))
driver.find_element_by_xpath('//*[@id="geetest-wrap"]/div/div[5]/a[1]').click()
 
time.sleep(5)
# 截图
driver.save_screenshot('验证码.png')
els = driver.find_elements_by_xpath('//div[@class="geetest_widget geetest_medium_fontsize"]')[0]
els.screenshot('bilibili.png')
# 9004选择一到四个点
number = get_code('./bilibili.png'9004)
print(number, type(number))
num = len(number.split('|')) - 1
for in range(num + 1):
    pic = number.split('|')[i]
    # print(a1)
    time.sleep(random.randint(13))
    x, y = pic.split(',')
    ActionChains(driver).move_to_element_with_offset(els, int(x), int(y)).click().perform()
    time.sleep(random.random() * 3)
time.sleep(random.random() * 2)
driver.find_element_by_xpath('//div[@class="geetest_commit_tip"]').click()
time.sleep(random.randint(3060))
url2 = 'https://www.bilibili.com/anime/index/?from_spmid=666.4.0.0#st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&page=1'
 
driver.get(url2)
print(driver.page_source)
driver.close()
posted @ 2021-12-17 17:15  布都御魂  阅读(178)  评论(0编辑  收藏  举报