# _*_coding:utf-8_*_
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import os,urllib.request,sys,importlib,time,winreg
def Login_in(username,password):
#教务管理系统网址
PostUrl = ""
#验证码网址
SecretCodeUrl = ""
#通过win注册表获得桌面路径地址
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, \
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', )
cwd= winreg.QueryValueEx(key, "Desktop")[0]
address = str(cwd) + "/image.jpg"
driver.get(PostUrl)
driver.find_element_by_name("txtUserName").send_keys(username)
#双input关联
driver.find_element_by_name('Textbox1').click()
driver.find_element_by_id('TextBox2').send_keys(password)
#验证码
#读取验证码网址、打开本地路径、写入、输入验证码
downpicture = urllib.request.urlopen(SecretCodeUrl).read()
local = open(address, 'wb')
local.write(downpicture)
local.close()
print(u"请从桌面寻找你的验证码")
print (u"请输入验证码:")
SecretCode = input()
driver.find_element_by_id('txtSecretCode').send_keys(SecretCode)
driver.find_element_by_xpath("//*[@id='Button1']").click()
def To_Grab_class(corm,username):
directUrl = "http://127.0.0.1/(mil3m1jzac4e0a55aqz5ky45)/xs_main.aspx?xh="+ username
driver.get(directUrl)
#鼠标悬停
chain = ActionChains(driver)
implement = driver.find_element_by_link_text(u"网上选课")
chain.move_to_element(implement).perform()
if corm == 1 :
driver.find_element_by_link_text("校选修课").click()
else :
driver.find_element_by_link_text("院系选修课").click()
def check_all():
checkboxs = driver.find_elements_by_xpath("//input[@type='checkbox']")
i=1
for click in checkboxs :
i=i+1
if i % 2 == 0 :
click.click()
driver.find_element_by_id("Button1").click() if __name__ == "__main__":
importlib.reload(sys)
print(u"请输入学号:")
username =input()
print(u"请输入密码:")
password = input()
print(u"校选修课请按1,院系选修课请按2 :")
corm = int(input())
#使用的 phentomjs浏览器 此地需要自行更改
driver = webdriver.PhantomJS(executable_path=r"d:\Grab_class\phantomjswindows\bin\phantomjs.exe")
Login_in(username,password)
To_Grab_class(corm,username)
check_all()

Python Selenium + phantomJS 模拟登陆教务管理系统 “抢课”的更多相关文章

  1. python selenium+phantomjs alert()弹窗报错

    问题:用selenium+phantomjs 模拟登陆,网页用JavaScript的alert("登陆成功")弹出框,但是用switch_to_alert().accept()报错 ...

  2. Python实现网站模拟登陆

    一.实验简介 1.1 基本介绍 本实验中我们将通过分析登陆流程并使用 Python 实现模拟登陆到一个实验提供的网站,在实验过程中将学习并实践 Python 的网络编程,Python 实现模拟登陆的方 ...

  3. Python+Selenium自动化-模拟键盘操作

    Python+Selenium自动化-模拟键盘操作   0.导入键盘类Keys() selenium中的Keys()类提供了大部分的键盘操作方法:通过send_keys()方法来模拟键盘上的按键. # ...

  4. Python+Selenium自动化 模拟鼠标操作

    Python+Selenium自动化 模拟鼠标操作   在webdriver中,鼠标的一些操作如:双击.右击.悬停.拖动等都被封装在ActionChains类中,我们只用在需要使用的时候,导入这个类就 ...

  5. python登陆教务管理系统

    想试着模拟登陆一些网站,这次先拿学校的教务管理系统练练手,写一下登陆的流程. 1.我们登陆的url:http://222.195.8.201,但我们所填的密码不是提交到这个页面上去,检查一下页面代码 ...

  6. python+selenium+PhantomJS批量投递智联简历(不要用自己的账号进行测试,请使用小号,很烦人的,哈哈哈)

    1.环境python2.7+selenium+PhantomJS(软件安装和库的安装网上都有教程我们跳过,so easy) 2.原理 绕过首页登录需要验证码,直接进入搜索栏,输入搜索的职位+地区搜索出 ...

  7. selenium 12306模拟登陆

    代码应用场景 :基于第三方打码网站模拟登陆12306 验证码识别 基于第三方平台超级鹰识别 超级鹰官网:http://www.chaojiying.com/user/ 超级鹰使用流程: 注册 登陆(用 ...

  8. python+selenium+PhantomJS爬取网页动态加载内容

    一般我们使用python的第三方库requests及框架scrapy来爬取网上的资源,但是设计javascript渲染的页面却不能抓取,此时,我们使用web自动化测试化工具Selenium+无界面浏览 ...

  9. 看我怎么扒掉CSDN首页的底裤(python selenium+phantomjs爬取CSDN首页内容)

    这里只是学习一下动态加载页面内容的抓取,并不适用于所有的页面. 使用到的工具就是python selenium和phantomjs,另外调试的时候还用了firefox的geckodriver.exe. ...

随机推荐

  1. 有关java里,nextLine()无法输入的问题

    在课后习题中用到了以下代码 public static void main(String[] args) { System.out.print("输入学生人数:"); int st ...

  2. deeplearning.ai 卷积神经网络 Week 1 卷积神经网络 听课笔记

    1. 传统的边缘检测(比如Sobel)手工设计了3*3的filter(或者叫kernel)的9个权重,在深度学习中,这9个权重都是学习出来的参数,会比手工设计的filter更好,不但可以提取90度.0 ...

  3. Linux 下非root用户使用docker

    Linux 下非root用户使用docker 通常我们使用linux系统的时候,最好是不要直接使用root账号,但是使用Docker的时候,默认又是不能使用非root用户的,关于原因,官方说法如下: ...

  4. 基于Xilinx FPGA的视频图像采集系统

    本篇要分享的是基于Xilinx FPGA的视频图像采集系统,使用摄像头采集图像数据,并没有用到SDRAM/DDR.这个工程使用的是OV7670 30w像素摄像头,用双口RAM做存储,显示窗口为320x ...

  5. bzoj:1703: [Usaco2007 Mar]Ranking the Cows 奶牛排名

    Description     农夫约翰有N(1≤N≤1000)头奶牛,每一头奶牛都有一个确定的独一无二的正整数产奶率.约翰想要让这些奶牛按产奶率从高到低排序.    约翰已经比较了M(1≤M≤100 ...

  6. android文件选择器、仿淘宝编辑页面、新手引导层等源码

    Android精选源码 单片机和安卓应用,传感器 文件选择器 android滑动选择的尺子view源码 android视频录制 视频压缩的源码 仿今日头条顶部导航指示器源码 Android框架+常用控 ...

  7. Spring配置集群定时任务

    正常配置定时任务的时候配置定时任务调度工厂的代码如下 <bean id="" class="org.springframework.scheduling.quart ...

  8. centos7 hue安装

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  9. [国嵌笔记][017][Makefile工程管理]

    Makefile的用途 1.make能够使整个程序的编译.链接只需一个命令就可以完成 2.make的工作主要依赖于Makefile的文件.Makefile文件描述了整个程序的编译.链接等规则,使之自动 ...

  10. 十二个 ASP.NET Core 例子——IOC

    目录 简单介绍 core自带IOC的实现解释 1.简单介绍 (个人理解) 是什么:IOC是一种设计原则,而非设计模式,是对流程控制,当你注入你需要的定制化类时,流程就确定了 怎么用:和IOC容器说你这 ...