哔哩哔哩点击验证码
'''
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(
1
,
3
))
driver.find_element_by_id(
'login-username'
).send_keys(
'18736709382'
)
# 输入密码
time.sleep(random.randint(
1
,
3
))
driver.find_element_by_id(
'login-passwd'
).send_keys(
'xiuxiu521@'
)
# 点击登录
time.sleep(random.randint(
1
,
3
))
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
i
in
range
(num
+
1
):
pic
=
number.split(
'|'
)[i]
# print(a1)
time.sleep(random.randint(
1
,
3
))
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(
30
,
60
))
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©right=-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()
本文作者:布都御魂
本文链接:https://www.cnblogs.com/wolvies/p/15703098.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步