python- selenium chrome自动登录360智脑

时间:2024-10-01 15:22:12

# -*-coding:UTF-8 -*-
import webbrowser as web
from selenium import webdriver
#pip install selenium -i https://pypi.douban.com/simple/
#python.exe -m pip install --upgrade pip -i https://pypi.douban.com/simple/
from selenium.webdriver.chrome.options import Options
import requests,os,time,re
# print('中间滑块验证,需要您自己滑动哦,最后点击进入体验!')
# time.sleep(8)
# https://sites.google.com/a/chromium.org/chromedriver/
options = Options()
# options.add_argument('--headless')
options.add_experimental_option('excludeSwitches', ['enable-automation'])
options.add_argument("--disable-blink-features=AutomationControlled")

driver = webdriver.Chrome(options=options)
url360='https://i.360.cn/login?src=pcw_chat&destUrl=https%3A%2F%2Fchat.360.cn%2Findex'
# urlxunfei2='https://xinghuo.xfyun.cn/desk'
driver.get(url360)
driver.maximize_window()
# logincard_tag = driver.find_element_by_class_name('<div role="tab" aria-disabled="false" aria-selected="true" class="ant-tabs-tab-active ant-tabs-tab">账号密码登录</div>')

logincard_tag = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[1]/div/div/div/div[1]/a')
logincard_tag.click()
input_tag = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div[1]/div/div[2]/form/div[1]/div/div/input')
input_tag.send_keys('136717187')  # 回车
password = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div[1]/div/div[2]/form/div[2]/div/div/input')
password.send_keys('IBM123')  # 登录

# login_tag = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div[1]/div/div[2]/form/div[5]/div/label/input')
login_tag = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div/div/div[2]/form/div[4]/div/label/input')
login_tag.click() #check box
 # //*[@id="js-sdk"]/div/div[2]/div/div/div/div[2]/form/div[5]/input

# login_tag2 = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div[1]/div/div[2]/form/div[6]/input')
login_tag2 = driver.find_element_by_xpath('//*[@id="js-sdk"]/div/div[2]/div/div/div/div[2]/form/div[5]/input')
login_tag2.click() #click login