from selenium import webdriver
from selenium.webdriver import ActionChains
import time
browser = webdriver.Chrome()
browser.maximize_window()
browser.get("https://www.baidu.com/")
tx=browser.find_element_by_id("kw")
tx.send_keys("腾讯视频")
search=browser.find_element_by_id("su")
search.click()
time.sleep(1)
txsp=browser.find_element_by_xpath("//div[@id='1']/h3[@class='t']")
txsp.click()
time.sleep(1)
browser.get('https://v.qq.com/')
time.sleep(1)
instant_login=browser.find_element_by_xpath("//div[@id='mod_head_user']/a")
instant_login.click()
time.sleep(1)
change=browser.find_element_by_xpath("//div[@class='login_btns']/a[1]")
change.click()
time.sleep(1)
browser.switch_to.frame("_login_frame_quick_")#跳转iframe
login=browser.find_element_by_xpath("//div[@id='bottom_qlogin']/a[1]")
login.click()
time.sleep(1)
input=browser.find_element_by_id("u")
input.send_keys("XXXXX")#填写账号
password=browser.find_element_by_id("p")
password.send_keys("XXXXX")#填写密码
button=browser.find_element_by_id("login_button")
button.click()
time.sleep(1)
frame=browser.find_element_by_xpath("//div[@id='newVcodeIframe']/iframe")
browser.switch_to.frame(frame)
hua=browser.find_element_by_id("tcaptcha_drag_button")
action = ActionChains(browser)# 实例化一个action对象
action.click_and_hold(hua).perform()# perform()用来执行ActionChains中存储的行为
action.reset_actions()
action.move_by_offset(183, 0).perform()# 移动滑块
action.reset_actions()
action.move_to_element(hua)
browser.switch_to.parent_frame()
browser.switch_to.parent_frame()#返回父页面
time.sleep(1)
browser.execute_script('window.scrollBy(0,2580)')
bianfu=browser.find_element_by_xpath("//div[@id='custommovie']/div[2]//li[1]")
bianfu.click()
now_url=browser.current_url
print(now_url)
print(browser.get_cookies())