zoukankan      html  css  js  c++  java
  • Selenium模拟登陆百度贴吧

    Selenium模拟登陆百度贴吧

    
    from selenium import webdriver
    from time import sleep
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    # dcap = dict(DesiredCapabilities.PHANTOMJS)
    # dcap["phantomjs.page.settings.userAgent"] = (
    # "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36"
    # )
    # driver =  webdriver.PhantomJS(executable_path='E:/phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin/phantomjs.exe',desired_capabilities=dcap)
    
    # options = webdriver.ChromeOptions()
    # options.add_argument('lang=zh_CN.UTF-8')
    # options.add_argument('user-agent="Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; ja-jp) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20"')
    # driver =  webdriver.Chrome(executable_path='D:chromedriver_win32chromedriver.exe',chrome_options=options)
    driver =  webdriver.Chrome(executable_path='D:chromedriver_win32chromedriver.exe')
    
    driver.get("https://tieba.baidu.com/index.html#")
    
    
    driver.find_element_by_xpath("//li[@class='u_login']/div/a").click()
    sleep(2)
    driver.find_element_by_class_name('login-username').click()
    
    username =driver.find_element_by_id('TANGRAM__PSP_4__userName')
    username.send_keys("413650185@qq.com")
    password = driver.find_element_by_id('TANGRAM__PSP_4__password')
    password.send_keys('luozhiyun2')
    driver.find_element_by_id('TANGRAM__PSP_4__submit').click()
    
    sleep(5)
    
    driver.find_element_by_css_selector("div#onekey_sign>a").click()
    
    driver.find_element_by_css_selector(".j_sign_btn.sign_btn.sign_btn_nonmember").click()
    driver.get_screenshot_as_file("D:/日志/2.png")
    driver.quit()
    
    
    
  • 相关阅读:
    ajax_基础1
    省市数据库脚本TblArea.
    c#中怎么使用dos命
    Lambda表达式
    面试收录
    .Net牛逼程序猿要懂得
    Web.config 配置文件
    sql 查询所有数据库、表名、表字段总结
    Json在net与页面之间的传递
    『转』SAP统驭科目解释
  • 原文地址:https://www.cnblogs.com/luozhiyun/p/8110723.html
Copyright © 2011-2022 走看看