python可视登陆小程序 一

信息中心

  • 自动登录可见 查课表
      from splinter.browser import Browser
      import time
    
      #登录页
      def login(b):
          #b.click_link_by_text("登录")
    
          b.fill("userid","xxx")  #填写账户密码
          b.fill("password","xxx")
          b.find_by_id("submitBtn").click()
    
          return b
    
      b=Browser(driver_name="chrome") #打开浏览器
      b.visit("http://xxx")
      login(b)
      b.visit("http://xxx")
    

    12306

      from splinter.browser import Browser
      x = Browser(driver_name="chrome")
      url = https://kyfw.12306.cn/otn/leftTicket/init
      x = Browser(driver_name="chrome")
      x.visit(url)
      #填写登陆账户、密码
      x.find_by_text(u"登录").click()
      x.fill("loginUserDTO.user_name","your login name")
      x.fill("userDTO.password","your password")
      #填写出发点目的地
      x.cookies.add({"_jc_save_fromStation":"%u4E1A%u6D77%2CSHH"})
      x.cookies.add({"_jc_save_fromDate":"2016-01-20"})
      x.cookies.add({u'_jc_save_toStation':'%u6C48%u5DDE%2CAOQ'})
      #加载查询
      x.reload()
      x.find_by_text(u"查询").click()
      #预定
      x.find_by_text(u"预订")[1].click()
      #选择乘客
      x.find_by_text(u"name")[1].click()
    

    库官网

selenium

```
from selenium import webdriver

driver = webdriver.Chrome()
driver.get('http://xxx')
driver.find_element_by_name("userid").send_keys("xx")
driver.find_element_by_name("password").send_keys("xx")
driver.find_element_by_id("submitBtn").click()
``` [详细介绍](http://www.cnblogs.com/fnng/p/3157639.html)
Written on February 2, 2017