'''username:201606032205
password:
vcode:kqqqu
service:http://218.59.189.229/login
lt:LT-261602-47Wcb3C5OdjvbeHp6uGlZsSWRFfh5N
execution:e2s1
_eventId:submit'''
# -*- coding: utf-8 -*-
import urllib.request
import urllib
import urllib.parse
import json
import time
import easygui as g
import sys
import imp
imp.reload(sys)
def c():
a=urllib.request.urlopen('http://218.59.189.229/cas/getVerificationCode?dateTime=1487597227638')
html=a.read()
with open('imageq.jpg','wb') as f:
f.write(html)
''' urllib.parse.urlencode用法:
from urllib import parse
>>> query = {
'name': 'walker',
'age': 99,
}
>>> parse.urlencode(query)
'name=walker&age=99'''
#调用urllib 将网址传入(需解析原网址)
head={}
head['User-Agent']='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/53.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36'
url='http://218.59.189.229/cas/login?service=http%3A%2F%2F218.59.189.229%2Flogin'
data={}#建立字典型
#依次传入到字典中
c()
a=str(input('请输入验证码'))
data['username']='201606032205'
data['password']='xxy1113521'
data['vcode']=a
data['service']='http://218.59.189.229/login'
data['lt']='LT-261602-47Wcb3C5OdjvbeHp6uGlZsSWRFfh5N'
data['execution']='e2s1'
data['_eventId']='submit'
#data['typoResult']='true'
data=urllib.parse.urlencode(data).encode('utf-8')
# 注意encode用法 必须加utf-8字段 按照文档规定必须 重写data
resp=urllib.request.Request(url,data,head)
#resp=urllib.request.urlopen(url,data,head)
response=urllib.request.urlopen(resp)
#response.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/53.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')
html=response.read().decode()#此处必须加utf-8 否则出现乱码无法查找
#print(html)
request=json.loads(html) #json.loads 读入内部 json.load 读入文件中的
#print(request['translateResult'][0][0]['tgt'])
#print(request['smartResult']['entries'])
print('登陆成功')
password:
vcode:kqqqu
service:http://218.59.189.229/login
lt:LT-261602-47Wcb3C5OdjvbeHp6uGlZsSWRFfh5N
execution:e2s1
_eventId:submit'''
# -*- coding: utf-8 -*-
import urllib.request
import urllib
import urllib.parse
import json
import time
import easygui as g
import sys
import imp
imp.reload(sys)
def c():
a=urllib.request.urlopen('http://218.59.189.229/cas/getVerificationCode?dateTime=1487597227638')
html=a.read()
with open('imageq.jpg','wb') as f:
f.write(html)
''' urllib.parse.urlencode用法:
from urllib import parse
>>> query = {
'name': 'walker',
'age': 99,
}
>>> parse.urlencode(query)
'name=walker&age=99'''
#调用urllib 将网址传入(需解析原网址)
head={}
head['User-Agent']='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/53.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36'
url='http://218.59.189.229/cas/login?service=http%3A%2F%2F218.59.189.229%2Flogin'
data={}#建立字典型
#依次传入到字典中
c()
a=str(input('请输入验证码'))
data['username']='201606032205'
data['password']='xxy1113521'
data['vcode']=a
data['service']='http://218.59.189.229/login'
data['lt']='LT-261602-47Wcb3C5OdjvbeHp6uGlZsSWRFfh5N'
data['execution']='e2s1'
data['_eventId']='submit'
#data['typoResult']='true'
data=urllib.parse.urlencode(data).encode('utf-8')
# 注意encode用法 必须加utf-8字段 按照文档规定必须 重写data
resp=urllib.request.Request(url,data,head)
#resp=urllib.request.urlopen(url,data,head)
response=urllib.request.urlopen(resp)
#response.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/53.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')
html=response.read().decode()#此处必须加utf-8 否则出现乱码无法查找
#print(html)
request=json.loads(html) #json.loads 读入内部 json.load 读入文件中的
#print(request['translateResult'][0][0]['tgt'])
#print(request['smartResult']['entries'])
print('登陆成功')