IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Selenium+PhantomJS(系列二:模拟登录淘宝)

    admin发表于 2016-10-09 04:15:06
    love 0

    Selenium+PhantomJS(系列二:模拟登录淘宝)

    from selenium import webdriver  
    driver = webdriver.PhantomJS(executable_path='/opt/phantomjs-2.1.1-linux-i686/bin/phantomjs')                   
      
    driver.get(“https://login.taobao.com/member/login.jhtml“)  
      
    driver.find_element_by_id("TPL_username_1").clear()  
    driver.find_element_by_id("TPL_password_1").clear()  
    driver.find_element_by_id("TPL_username_1").send_keys(self.username)  
    driver.find_element_by_id("TPL_password_1").send_keys(self.password)  
      
    driver.find_element_by_id("J_SubmitStatic").click()  
      
    #driver.get_cookies()取得cookie  
    cookie = "; ".join([item["name"] + "=" + item["value"] +"\n" for item in driver.get_cookies()])  
    print cookie  
    #然后带上cookie登录后的页面去请求页面

    Selenium+PhantomJS(系列二:模拟登录淘宝)



沪ICP备19023445号-2号
友情链接