美文网首页
python爬虫之selenium英雄联盟小Demo

python爬虫之selenium英雄联盟小Demo

作者: Pickupthesmokes | 来源:发表于2018-12-30 00:56 被阅读0次
    #英雄联盟官网登录页面
    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)

    相关文章

      网友评论

          本文标题:python爬虫之selenium英雄联盟小Demo

          本文链接:https://www.haomeiwen.com/subject/nemmlqtx.html