python爬虫之selenium英雄联盟小Demo

2018-12-30  本文已影响0人  Pickupthesmokes
#英雄联盟官网登录页面
from selenium import webdriver
import time
driver = webdriver.Chrome(
    executable_path='/home/ljh/桌面/driver/chromedriver'
)
driver.get('https://lol.qq.com/')
time.sleep(2)
driver.find_element_by_xpath('//p[@class="unlogin"]/a').click()
time.sleep(2)
#如果要找的节点在iframe子页面中,这时要切换到子页面中
driver.switch_to_frame('loginIframe')
driver.find_element_by_id('switcher_plogin').click()
#账号输入框    driver.find_element_by_xpath('//input[@id="u"]').send_keys('1970008493')
#密码输入框
driver.find_element_by_xpath('//input[@id="p"]').send_keys('19971127ljk')
#登录按钮,点击
driver.find_element_by_xpath('//input[@id="login_button"]').click()
cookies = {cookie['name']:cookie['value'] for cookie in     driver.get_cookies()}
print(cookies)
上一篇下一篇

猜你喜欢

热点阅读