发布于2024-11-10 09:29 阅读(867) 评论(0) 点赞(26) 收藏(4)
基本上,我尝试登录 Snapchat,但每次都会触发验证码,因此为了避免这种情况,我在这里阅读了有关未检测到的 chrome 驱动程序的信息:https: //github.com/ultrafunkamsterdam/undetected-chromedriver/blob/master/undetected_chromedriver/devtool.py
我决定尝试一下,但验证码仍然被激活......下面是我的代码:
import undetected_chromedriver as uc
self.driver = uc.Chrome()
def login(self):
print('GET LOGIN')
self.driver.get("https://accounts.snapchat.com/accounts/v2/login")
print(self.user_creds['username'])
try:
accept_all_button = self.driver.find_element(By.XPATH, "//button[span[contains(text(), 'Accept All')]]")
accept_all_button.click()
print("Clicked 'Accept All' button to remove overlapping elements.")
time.sleep(5) # Wait for the page to update
except Exception as e:
print(f"'Accept All' button not found, proceeding to click 'Accept' button.{e}")
# Wait for the username input to be present
WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.NAME, "accountIdentifier"))
)
print('found 1')
username_input = self.driver.find_element(By.NAME, "accountIdentifier")
username_input.send_keys(self.user_creds['username'])
print('found 2',username_input)
time.sleep(3)
next_button =WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Next')]"))
)
#next_button = self.driver.find_element(By.CSS_SELECTOR, "btn.btn-lg.btn-default")
print("next",next_button)
time.sleep(2) # Give some time for the scrolling to complete
next_button.click()
print('found 3')
time.sleep(10)
try:
WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//h1[@class='login-challenge-title' and contains(text(), 'Log in to Snapchat')]"))
)
print("Element found: Log in to Snapchat")
except Exception as e:
print("Element not found: Log in to Snapchat")
password_input = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.NAME, "password"))
)
password_input.send_keys(self.user_creds['password'])
password_input.send_keys(Keys.RETURN)
print('found 4')
# Wait for some time to ensure login is processed
time.sleep(10)
print("Logged in successfully!")
有人有使用这个包并绕过验证码的经验吗?
作者:黑洞官方问答小能手
链接:https://www.pythonheidong.com/blog/article/2045415/c943c74b3a3471437cc9/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!