分享

yanzhengma

 217小月月坑 2015-12-10
#!usr/bin/env python     
#-*- coding: utf-8 -*-

import os
import urllib2
import urllib
import cookielib
import re

Img_URL='http://www./api/captcha/'
Login_URL='http://www./account/loginform'
Class_URL='http://www./'
def login():
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
#get img
img_req=urllib2.Request(Img_URL)
img_response=opener.open(img_req)
try:
out=open('/home/ym/code','wb')
#print img_response.read()
out.write(img_response.read())
out.flush()
out.close()
print 'get code success'
except IOError:
print 'file wrong'
#input code
img_code=raw_input("please input code: ")
print 'your code is %s'%img_code
#login
LoginData = {
'Email': '2027598917@qq.com',
'Password': 'hp201112701254',
'Captcha': img_code,
'Remember': 'true',
'Remember': 'false',
'Ver': 'True',
'AnonID': 'bf976050-bf60-4acd-b892-c3de2d0276de',
'Title':''
};
login_req = urllib2.Request(Login_URL, urllib.urlencode(LoginData));
login_req.add_header('User-Agent', "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36");
login_response=opener.open(login_req)
print 'login success'
fout=open("/home/ym/tt.txt","w")
fout.write(login_response.read())
fout.close()
#load class info
print 'load class'
fout=open('/home/ym/t1.txt','w')
fout.write(opener.open(Class_URL).read())
fout.close()
if __name__=='__main__':
login()

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约