APP淘菜猫自动签到助手,qiweb情人节版: taocaimaoForPython: 包含,随机定时执行淘菜猫 多账号批量: 登录,签到,评价订单,确认收货,抽奖,查询积分。 查看优惠卷。 并生成html清单 最后发送邮件通知

#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# Form fd request
#
# Created: 2016年6月21日13:21:35
#update 2016年10月21日14:12:45
#update 2017年2月12日12:04:25 添加 自动签到,发送邮件, 自动确认收货 评价 抽奖,优惠卷汇总
#upadte 2017年1月17日 18:11:34
# by: qiweb
#
# WARNING! All changes made in this file will be lost!
import urllib
import urllib2
import cookielib
import json
import time
import random
import os
import sys
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
 
 
class qiwebTaoCaiMao:
USER_NAME=["131894616","15889562","189641892","131172603"]#136771294
PASSWROD=["123456","123456","123456","123456"]
 
CLENTID=["22","1ed0c8c5ba1f730951dc8f97cf6b4614","f4efeb52f9cc09cc165c67077b410e91","36e4f2e99002c381f46aec156d04e4c8"]
 
CLENTID=["1ed0c8c5ba1f730951dc8f97cf6b4614","f3c737a1e04aaf34c64b39f2448f5980","f4efeb52f9cc09cc165c67077b410e91","36e4f2e99002c381f46aec156d04e4c8"]
CLENTID=["1ed0c8c5ba1f730951dc8f97cf6b4614","b888768e8d6a215aa2147678a2719319","f4efeb52f9cc09cc165c67077b410e91","90a117db05b23dc3b56d2e8f197d818d"]
CLENTID=["1ed0c8c5ba1f730951dc8f97cf6b4614","44bf2407d25da311614392ec08d1a22a","f4efeb52f9cc09cc165c67077b410e91","90a117db05b23dc3b56d2e8f197d818d"]
CLENTID=["1ed0c8c5ba1f730951dc8f97cf6b4614","7d078114261ef556f4b1175abf264238","f4efeb52f9cc09cc165c67077b410e91","90a117db05b23dc3b56d2e8f197d818d"]
CLENTID=["1ed0c8c5ba1f730951dc8f97cf6b4614","e5d24f6e5ff41f36f07dbc4ca83b7d42","d6c0186bf36e92355ebf127107903c4f","90a117db05b23dc3b56d2e8f197d818d"]
 
PING_JIA=["今天的蔬菜很新鲜","老板人很好,还送了香菜","今天送菜很及时,满意","最近菜价不稳定啊","淘菜猫这个软件真不错,方便","好评 ,买菜很方便","好评还能抽奖","好好好,很好","今天又不知道吃啥了"]
 
 
user_index=1
Host="http://m.taocaimall.com"
cookievalue=None
user_now=None
 
MSGS=""
juan_msg=""
jifen_choujiang=""
 
appLongoutUrl="http://m.taocaimall.com/taocaimall/appLongout.json"
appLongin1="https://m.taocaimall.com/taocaimall/appLongin.json"
 
 
appLongin2="http://m.taocaimall.com/taocaimall/saveClientId.json"
appLongin3="http://m.taocaimall.com/taocaimall/buyer/getRongCloudToken.json"
 
discountCouponUrl="http://m.taocaimall.com/taocaimall/buyer/list_discountCoupon_1.json"
 
# 查看订单
orderUrl="http://m.taocaimall.com/taocaimall/buyer/order.json?order_status=all&currentPage=1"
 
#确认收货
ok_url="http://m.taocaimall.com/taocaimall/buyer/showGoodsImageOfOrder.json"
 
Referer="" #http://m.taocaimall.com/taocaimall/iphoneSEActivityforAppClient.htm?sessionId=032BA8B6CD5A9B7F3BDE8A24E8A7C5E5
 
#评价 {"op_flag":"success","info":"确认收货及评价成功,获得10积分","lotteryInfo":"恭喜你获得一次抽奖机会","lottyerUrl":"http://m.taocaimall.com/taocaimall/iphoneSEActivityforAppClient.htm?sessionId=032BA8B6CD5A9B7F3BDE8A24E8A7C5E5"}
pinjia_url="http://m.taocaimall.com/taocaimall/buyer/order_cofirm_save_and_saveEvaluate.json"
 
#总积分
zong_jifen_url="http://m.taocaimall.com/taocaimall/buyer/getintegral.json"
# 积分列表
xiangqiang_jifen_url="http://m.taocaimall.com/taocaimall/buyer/getIntegralLogList.json"
 
User_Agent="Mozilla/5.0 (Linux; Android 5.1.1; Redmi 3 Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36"
rongCloudToken=None
JSESSIONID=None
sessionid=None
userId=None
addrInfo=None
telephone=None
 
#####################################发送邮件模块start##########
import smtplib
from email.mime.text import MIMEText
mailto_list = ["zqijava@163.com"]
mail_host = "smtp.163.com" # 设置服务器
mail_user = "zqijava" # 用户名
mail_pass = "5555" # 口令
mail_postfix = "163.com" # 发件箱的后缀
 
def send_mail(self,to_list, sub, content): # to_list:收件人;sub:主题;content:邮件内容
dat=time.strftime('%Y-%m-%d %H:%M:%S 周 %w', time.localtime(time.time()))
me = "自动定时任务%s"%dat + "<" + self.mail_user + "@" + self.mail_postfix + ">" # 这里的hello可以任意设置,收到信后,将按照设置显示
msg = self.MIMEText(content, _subtype='html', _charset='UTF-8') # 创建一个实例,这里设置为html格式邮件
msg['Subject'] = sub # 设置主题
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
s = self.smtplib.SMTP()
s.connect( self.mail_host) # 连接smtp服务器
s.login( self.mail_user, self.mail_pass) # 登陆服务器
s.sendmail(me, to_list, msg.as_string()) # 发送邮件
s.close()
return True
except Exception, e:
print str(e)
return False
'''
if __name__ == '__main__':
if send_mail(mailto_list, "hello", "<a href='http://www.cnblogs.com/xiaowuyi'>小五义</a>"):
print u"发送成功"
else:
print u"发送失败"
'''
#####################################发送邮件模块end##########
 
#------------------------------------do_get_post------------------------------------
def do_get_post(self,url,postdata):
time.sleep(2)#两秒一次请求
text = None
self.User_Agent="PersonalTarget/1.2 CFNetwork/808.3 Darwin/16.3.0"
try:
req = urllib2.Request(url,
postdata) # urllib2.Request: the HTTP request will be a POST instead of a GET when the data parameter is provided.
 
 
req.add_header('User-Agent', self.User_Agent)
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
req.add_header('Cache-Control', 'no-cache')
 
req.add_header('Accept-Encoding', 'gzip, deflate')
req.add_header('Accept-Language', 'zh-cn')
 
req.add_header('Cookie', self.cookievalue)
print u"提交cookievalue:",self.cookievalue
req.add_header('Accept', '*/*')
req.add_header('Connection', 'Keep-Alive')
req.add_header('Connection', 'keep-alive')
 
if(url.find("getlotteryCount.json")!=-1):#判断抽奖1
req.add_header('Referer', self.Referer)
pass
if(url.find("getiphoneSE.json")!=-1):#判断抽奖2
req.add_header('Referer', self.Referer)
req.add_header('Origin', 'http://m.taocaimall.com')
pass
 
resp = urllib2.urlopen(req)
if(url.find("appLongin.json")!=-1):#判断为登录获取cookie
setcookie=resp.headers.headers[7]
index=setcookie.find("JSESSIONID")
xxx=setcookie[index:index+43]
if(len(xxx)>3):
self.cookievalue=xxx
text = resp.read()
 
if (url.find("viewSignin.htm") == -1): # 判断为查看积分
print text
except Exception as es:
print u'哎呀,请求又超时了!5秒后重试',es,url,postdata#,req.get_header()
time.sleep(5) # 前面请求太多等待5秒再
#self.go_main(1)
self.do_get_post(url,postdata)
#respInfo = resp.info()
# print respInfo
 
return text
 
# ------------------------------------do_get_post_html------------------------------------
#目前还没使用此函数
def do_get_post_html(self, url, postdata):
self.User_Agent="Mozilla/5.0 (Linux; Android 5.1.1; Redmi 3 Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36"
req = urllib2.Request(url,
postdata) # urllib2.Request: the HTTP request will be a POST instead of a GET when the data parameter is provided.
 
req.add_header('User-Agent', self.User_Agent)
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
req.add_header('Cache-Control', 'no-cache')
req.add_header('Accept', '*/*')
req.add_header('Connection', 'Keep-Alive')
resp = urllib2.urlopen(req)
# respInfo = resp.info()
# print respInfo
text = resp.read()
print text
return text
 
#------------------------------------登录------------------------------------
def login(self,username,password):
self.user_now=username
baiduSpaceEntryUrl =self.Host# "https://m.taocaimall.com/taocaimall/appLongin.json"
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
resp = urllib2.urlopen(baiduSpaceEntryUrl)
loginBaiduUrl = self.appLongin1#"https://passport.baidu.com/?login";
'''para = {"requestmodel":{"drivice": "android",
"username": USER_NAME[0],
"clientId": "cbe0cb9720d3d1a4f4e5e40ecb2c6435",
"password": PASSWROD[0]
}
}
 
postData = urllib.urlencode(para)
'''
postData="requestmodel={%22drivice%22:%22android%22,%22username%22:%22"+username+"%22,%22clientId%22:%22cbe0cb9720d3d1a4f4e5e40ecb2c6435%22,%22password%22:%22"+password+"%22}"
text=self.do_get_post(loginBaiduUrl,postData)
print text
dicttext=json.loads(text)
self.sessionid=dicttext["sessionid"]
self.userId=dicttext["userId"]
self.addrInfo=dicttext["addrInfo"]
 
postData="requestmodel={%22drivice%22:%22android%22,%22clientid%22:%22cbe0cb9720d3d1a4f4e5e40ecb2c6435%22}"
text = self.do_get_post(self.appLongin2, postData)
postData=""
text = self.do_get_post(self.appLongin3, postData)
text = self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/address.json", postData)
yy=json.loads(text)
#yydic=yy.list
self.telephone=yy['list'][0]["telephone"]
 
# self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/goodscart_notify.json ", postData)
# self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/account.json", postData)
# self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/account_avatar.json", postData)
# self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/message_unread_count.json", postData)
# self.do_get_post("http://m.taocaimall.com/taocaimall/buyer/order_notify.json", postData)
 
pass
 
#------------------------------------查询订单------------------------------------
def queryOrder(self):
pass
 
#------------------------------------查询积分------------------------------------
def queryAccount(self):
 
self.zong_jifen_url
text = self.do_get_post(self.zong_jifen_url, "")
mydirc = json.loads(text)
integral=mydirc["integral"]
 
 
#积分明细 先注释
# pp='requestmodel={ "type" : "integralIncome", "currentPage" : "1"}'
# textY = self.do_get_post(self.xiangqiang_jifen_url,pp)
# mydircy = json.loads(textY)
print u'电话:%s,总积分:%s' % (self.telephone,integral)
self.jifen_choujiang = self.jifen_choujiang + '<br>电话:%s _ 总积分:%s' % (self.telephone,str(integral))
 
pass
 
# ------------------------------------查询优惠卷------------------------------------
htmltext=""
def querydiscountCoupon(self):
htmltext=""
text = self.do_get_post(self.discountCouponUrl,"")
mydirc=json.loads(text)
mylist=mydirc["list"]
for vo in mylist:
vo["user"]=self.telephone
htmltext=htmltext+self.htmltd.decode('utf-8').format(**vo).encode('utf-8')
pass
#print htmltext #这是拼装的table td
yyy=self.htmlstart+self.htmlth+htmltext+self.htmlend
self.juan_msg=self.juan_msg+yyy
self.saveHTML(yyy,'taocaimao_%s.html'%time.strftime("%Y%m%d", time.localtime()) )
 
#随机获取好评语句
def getPinjia(self):
yy=self.PING_JIA[random.randint(0, len(self.PING_JIA))]
self.jifen_choujiang=self.jifen_choujiang+"\n 随机评价语:%s"%yy
return yy
 
# ------------------------------------抽奖------------------------------------
def getHongBao(self):
print u'用户%s正在抽奖' % (self.telephone)
# 抽奖
test = self.cookievalue.split("=")[1]
uurl = 'http://m.taocaimall.com/taocaimall/iphoneSEActivityforAppClient.htm?sessionId=%s' % test
 
self.Referer = uurl
#textz = self.do_get_post(uurl, "")
# 看可以抽奖次数
uurl2 = 'http://m.taocaimall.com/taocaimall/getlotteryCount.json'
ppps = 'requestmodel={"telephone":"%s","openid":"","source":"APP","sessionId":"%s"}'%(self.telephone,test)
textm = self.do_get_post(uurl2, ppps)
yy = json.loads(textm)
iphoneSEcanTrophyCount=int(yy["iphoneSEcanTrophyCount"])#可以抽奖的次数
for i in range(0,iphoneSEcanTrophyCount):
# 开始抽奖
uurl3 = 'http://m.taocaimall.com/taocaimall/getiphoneSE.json'
# pppsn='requestmodel={"telephone":"'+self.telephone+'","openid":"","source":"APP","sessionId":"'+test+'"}'
#ppa='requestmodel=%7B%22telephone%22%3A%22%s%22%2C%22openid%22%3A%22%22%2C%22source%22%3A%22APP%22%2C%22sessionId%22%3A%22%s%22%7D'%(self.telephone,test)
textn = self.do_get_post(uurl3, ppps)
#mm=json.load(textn)
#money= mm["money"]
self.jifen_choujiang = self.jifen_choujiang + '\n 用户%s成功抽取%s元优惠卷'%(self.telephone,textn)
print u'用户%s成功抽取%s元优惠卷'%(self.telephone,textn)
 
# ------------------------------------确认收货,评价 ------------------------------------
def evaluationLottery(self):
print u'用户%s正在确认收货和评价订单' % (self.telephone)
#查看订单
#http://m.taocaimall.com /taocaimall/buyer/order.json?order_status=all&currentPage=1
#订单状态
# "order_status":"20" 下单成功了,待准备,发货
#order_status = 0 订单已取消
#"order_status":"50" 已经完成也签到成功了
#"order_status":"40" 已经确认收货,待评价 订单超过5天不可评价
#"order_status": 108 订单准备中,可以确认收货 及评价
text = self.do_get_post(self.orderUrl, "")
mydirc = json.loads(text)
mylist = mydirc["orderForms"]
 
#import sys
#reload(sys)
#sys.setdefaultencoding('utf8')
 
 
for i in range(0,3):
vo=mylist[i]
order_status=vo["order_status"]
if(order_status=='108'):#可以确认收货和评价
id = vo["id"]#订单编号
print u'订单编号:%s'%id
#确认收货
textx = self.do_get_post(self.ok_url,'requestmodel={ "buyerOrderId" : "%s"}'%id)
#确认收货 及评价
pps='jsonModel={"evaluatevalueStore514" : "5","isOnTime" : "1","orderId" : "'+id+'","ship_service" : "5","evaluateinfoStore514" : "'+self.getPinjia()+'","stockout514" : "0"}'
 
#jsonModel={"evaluatevalueStore514":"5","isOnTime":"1","orderId":"%s"%id,"ship_service":"5","evaluateinfoStore514":"送货很及时,满意","stockout514":"0"}
texty = self.do_get_post(self.pinjia_url,str(pps))
self.jifen_choujiang = self.jifen_choujiang + '订单编号:%s'%id+str(texty)
pass
pass
#for vo in mylist:
# pass
#抽奖页面
#http://m.taocaimall.com/taocaimall/iphoneSEActivityforAppClient.htm?sessionId=2B78F8B650C82566D40F6552C44E6222
#查看中奖历史记录
#http://m.taocaimall.com/taocaimall/showMyActivityHistory.htm?phone=18616851455
 
pass
 
 
allviewSignin=""
#------------------------------------签到------------------------------------
def signIn(self,cid):
#377d774a074c1b539636790e330027cf
#f4efeb52f9cc09cc165c67077b410e91,36e4f2e99002c381f46aec156d04e4c8,1ed0c8c5ba1f730951dc8f97cf6b4614
newclientId="&clientId=%s&versionValue=1.96"%cid
time.sleep(2)#前面请求太多等待3秒再签到
#viewSignin="http://m.taocaimall.com/taocaimall/buyer/viewSignin.htm?sessionId=%s%s"%(self.sessionid,newclientId)
viewSignin="http://m.taocaimall.com/taocaimall/buyer/signInMainInfo.json"
print viewSignin
self.allviewSignin = self.allviewSignin+viewSignin+ self.telephone
#============================== 查看签到开始
req = urllib2.Request(viewSignin,
"") # urllib2.Request: the HTTP request will be a POST instead of a GET when the data parameter is provided.
 
req.add_header('Host', 'm.taocaimall.com')
req.add_header('Connection', 'keep-alive')
print u"cookie:%s" % self.cookievalue
req.add_header('Cookie', self.cookievalue)
# req.add_header('Content-Length', '19')
req.add_header('Accept', 'application/json, text/javascript, */*')
req.add_header('Origin', 'http://m.taocaimall.com')
req.add_header('X-Requested-With', 'XMLHttpRequest')
req.add_header('User-Agent',
'Mozilla/5.0 (Linux; Android 5.1.1; Redmi 3 Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36')
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
req.add_header('Referer', viewSignin)
req.add_header('Accept-Encoding', 'gzip, deflate')
req.add_header('Accept-Language', 'zh-CN,en-US;q=0.8')
resp = urllib2.urlopen(req)
 
#setcookie = resp.headers.headers[4]
#index = setcookie.find("JSESSIONID")
#signincookievalue = setcookie[index:index + 43]
 
 
text = resp.read()
# ==============================查看签到结束
 
dictinfo = json.loads(text)
xx=dictinfo["xx"]
if (xx == ""):
print u'%s,打开签到界面失败!' % self.user_now
print u'打开查看积分也没失败,正在重新尝试。。'
#self.signIn(cid) # 如果没有取得 查看积分的cookie重新请求
 
print u'%s,为xx的值' % xx
#text = self.do_get_post(viewSignin, "")
#index=text.find('xx=')
# xx=text[index:index+35]
#print xx
postdata = "requestmodel=%7B%7D"#{}
Signinurl="http://m.taocaimall.com/taocaimall/buyer/signInAndGotGift.json?clientId=%s&xx=%s&%s"%(cid,xx,postdata)
#"http://m.taocaimall.com/taocaimall/buyer/signIn.json?sessionId=%s&%s&%s%s"%(self.sessionid,xx,postdata,newclientId)
#http://m.taocaimall.com/taocaimall/buyer/signIn.json?sessionId=84C84FCFC7881DD6F8FD88B58A9BD336&xx=ac1f09320307aac618403720968ccc13&clientId=f4efeb52f9cc09cc165c67077b410e91&versionValue=1.96
print u"Signinurl:%s"%Signinurl
#text = self.do_get_post(Signinurl, "requestmodel=%7B%7D")
 
postdata="requestmodel=%7B%7D"
#=====================签到开始
 
time.sleep(3) # 前面请求太多等待3秒再签到
 
try:
req = urllib2.Request(Signinurl) # urllib2.Request: the HTTP request will be a POST instead of a GET when the data parameter is provided.
req.add_header('Host', 'm.taocaimall.com')
req.add_header('Connection', 'keep-alive')
print u"cookie22:%s"%self.cookievalue
#print u"cookie11:%s" % signincookievalue
#if(len(signincookievalue)<3):
 
 
req.add_header('Cookie',self.cookievalue)
#req.add_header('Content-Length', '19')
req.add_header('Accept', 'application/json, text/javascript, */*')
req.add_header('Origin', 'http://m.taocaimall.com')
req.add_header('X-Requested-With', 'XMLHttpRequest')
req.add_header('User-Agent',
'Mozilla/5.0 (Linux; Android 5.1.1; Redmi 3 Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36')
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
req.add_header('Referer', viewSignin)
req.add_header('Accept-Encoding', 'gzip, deflate')
req.add_header('Accept-Language', 'zh-CN,en-US;q=0.8')
req.add_header('Accept-Charset', 'utf-8, iso-8859-1, utf-16, *;q=0.7')
resp = urllib2.urlopen(req)
 
 
text = resp.read()
self.MSGS=self.MSGS+"\n用户%s的签到信息:%s"%(self.user_now,text)
print self.MSGS
 
if text.find("今日签到获得积分") !=-1:#{"op_flag":"success","info":"今日签到获得积分:15","integral":"15","nextIntegral":"20","userIntegral":"42","nextTime":"5"}
 
print "用户%s的签到信息:"% self.user_now
elif text.find("账号已经签到过了") !=-1:#{"op_flag":"fail","info":"喵:账号已经签到过了哦~"}
pass
elif text.find("喵:没收到信息") != -1: # {"op_flag": "fail", "info": "喵:没收到信息,没有签到成功哦~建议您退出再试试吧~"}
print "clientId:%s已过期,用户%s没有签到成功"%(cid,self.user_now)
pass
 
 
except ValueError as ab:
 
print u'签到失败正在重试\n原因:网络超时。。。。',ab
self.go_main(1)
return
#=====================签到结束
pass
 
#------------------------------------退出登录------------------------------------
def appLongout(self):
 
text=self.do_get_post(self.appLongoutUrl, "")
dictinfo = json.loads(text)
if(dictinfo["op_flag"]=="success"):
print u'%s,成功退出!'%self.user_now
else:
print '%s,成功失败!'%self.user_now
pass
 
# ------------------------------------批量操作 签到------------------------------------
def go_main(self,option_type):
for i in range(self.user_index, 4):
 
# 登录
self.login(self.USER_NAME[i], self.PASSWROD[i])
if option_type==1:
# 查看积分 和签到
self.signIn(self.CLENTID[i])
elif (option_type==2):
#查看优惠卷
self.querydiscountCoupon()
elif (option_type==3):
#查看优惠卷
self.evaluationLottery()
elif (option_type == 5):
# 查看积分
self.queryAccount()
elif (option_type == 6):
# 抽奖
self.getHongBao()
 
# 退出登录
#self.appLongout()
if i==3:
print u"全部账号签到完毕"
'''
if self.send_mail(["zqijava@163.com"], "淘菜猫签到通知", "<font color=red>%s</font>"%self.MSGS):
print u"发送成功"
else:
print u"发送失败"
print u"要见到的地址\n",self.allviewSignin
 
exit'''
else:
#设定下一个账号登录间隔
#input("input any key to next exit")
##self.appLongout()
x = random.random() * 25
print u'%d秒后开始登录下一个账号'%x
time.sleep(x)
def test(self):
list=[{"op_flag":"success","info":"操作成功","list":[{"id":"1868971","favorable_money":"12","origin_price":"29","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"vaid","begin_date":"2016-06-17","code":"625dc124","type":"普通优惠券","validity_date":"2016-06-24"},{"id":"1921884","favorable_money":"6","origin_price":"42","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"vaid","begin_date":"2016-06-22","code":"27dd8d27","type":"普通优惠券","validity_date":"2016-06-25"},{"id":"1930141","favorable_money":"10","origin_price":"69","useType":"3","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"vaid","useTypeInfo":"蔬果专区欢乐送","begin_date":"2016-06-23","code":"MTFkNzI4","type":"专区优惠券","validity_date":"2016-06-29"},{"id":"956946","favorable_money":"1","origin_price":"29","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-14","code":"MGZmYzVh","type":"普通优惠券","validity_date":"2016-06-21"},{"id":"956945","favorable_money":"2","origin_price":"29","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-13","code":"ZDFiNWYx","type":"普通优惠券","validity_date":"2016-06-20"},{"id":"1868970","favorable_money":"5","origin_price":"39","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-17","code":"70b51030","type":"普通优惠券","validity_date":"2016-06-20"},{"id":"956944","favorable_money":"2","origin_price":"29","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-12","code":"NTQyYTky","type":"普通优惠券","validity_date":"2016-06-19"},{"id":"1793855","favorable_money":"5","origin_price":"39","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-14","code":"bb5da141","type":"普通优惠券","validity_date":"2016-06-17"},{"id":"956943","favorable_money":"3","origin_price":"29","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-09","code":"MWJmMmUz","type":"普通优惠券","validity_date":"2016-06-16"},{"id":"1779856","favorable_money":"5","origin_price":"39","useType":"2","description":"凡满足本券使用金额且不与淘菜猫其他优惠同享(促销、满赠、换购、首单等)均可使用","timeFlag":"invaid","begin_date":"2016-06-13","code":"3844de4c","type":"普通优惠券","validity_date":"2016-06-16"}]},
 
]
 
#--------------------------------导出清单 开始----------------------------
htmlstart='''\
<html>
<head><!--pc--><title>python 获取淘菜猫的优惠卷</title><meta content="text/html; charset=utf-8" http-equiv="content-type" />
<style>
table.dataintable {
border: 1px solid #888888;
border-collapse: collapse;
font-family: Arial,Helvetica,sans-serif;
margin-top: 10px;
width: 100%;
}
table.dataintable th {
background-color: #CCCCCC;
border: 1px solid #888888;
padding: 5px 15px 5px 5px;
text-align: left;
vertical-align: baseline;
}
table.dataintable td {
background-color: #EFEFEF;
border: 1px solid #AAAAAA;
padding: 5px 15px 5px 5px;
vertical-align: text-top;
}
</style>
</head>
<body>
<table class="dataintable">
'''
htmlth='''\
<tr>
<th>user </th>
<th>id </th>
<th>favorable_money </th>
<th>origin_price </th>
<th>useType </th>
<th>description </th>
<th>timeFlag </th>
<th>begin_date </th>
<th>code </th>
<th>type </th>
<th>validity_date </th>
 
</tr>
'''
 
htmltd='''\
<tr>
<td>{user}</td>
<td>{id}</td>
<td>{favorable_money}</td>
<td>{origin_price}</td>
<td>{useType}</td>
<td>{description}</td>
<td>{timeFlag}</td>
<td>{begin_date}</td>
<td>{code}</td>
<td>{type}</td>
<td>{validity_date}</td>
</tr>
'''
htmlend='''\
<tr>
<th colspan="11">分页代码 </th>
</tr>
</table>
</body>
</html>
'''
'''
truncate()表示清空文件
write()写入文本
'''
def saveHTML(self,html,filename):
#print html
f = open(filename, 'a')
#f.truncate()
f.write(html)
f.closed
print u'文件%s生成成功!'%filename
pass
 
 
if __name__=="__main__":
 
 
'''for i in range(1,5):
for j in range(1,5):
pass
for k in range(1,5):
if( i != k ) and (i != j) and (j != k):
print i,j,k
exit
'''
mao=qiwebTaoCaiMao()
distext=u'''
欢迎使用{淘菜猫智能系统Python版本 V2017}
菜单指令【1、批量签到 , 2、批量生产优惠卷清单,3、设置账号起始位置,4、退出系统】
开始签到中.............
'''
print distext
 
# print u'测试代码要删除'
#
#
# #mao.go_main(3) # 确认收货 和评价 抽奖
# mao.go_main(6) # 抽奖
# mao.go_main(5) # 查看积分
# exit()
 
filename='taocaimao_%s.html'%time.strftime("%Y%m%d", time.localtime())
if os.path.exists(filename) :
print u'系统检测到%s 文件已经存在,说明今日已签到,若想重新签到,请手动删除文件%s'%(filename,os.path.split(os.path.realpath(__file__))[0]+"\\"+filename)
print u'\n6秒后程序自动退出'
time.sleep(6)
exit()
 
m=random.randint(1,10)#设定随机 n分钟 开始执行
print u"程序随机%s分钟 开始执行"%m
time.sleep(m*60)
 
 
 
mao.go_main(1)#签到
mao.go_main(3)#确认收货 和评价 抽奖
mao.go_main(2)#获取积分和优惠券
 
mao.go_main(6) # 抽奖
mao.go_main(5) # 查看积分
 
 
 
if mao.send_mail(["908701702@qq.com"], "淘菜猫签到优惠卷通知", "<h2>今日签到结果:</h2><br><font color=red>%s</font><br><h2>确认收货,评价,抽奖,积分信息:</h2><br>%s<br><h2>今日优惠卷汇总结果:</h2><br>%s" %(mao.MSGS ,mao.jifen_choujiang , mao.juan_msg)):
print u"发送成功"
else:
print u"发送失败"
'''
while True:
menu= raw_input("请输入指令:")
if menu=='1':
# 签到
mao.go_main(1)
elif menu=='2':
# 查了积分
mao.go_main(2)
elif menu=='3':
pass
elif menu=='4':
exit
else:
print u'你是在开玩笑吧,就没你想要的功能'
 
'''
 
 
 
'''
Cache-Control: no-cache, no-store, max-age=0
Content-Language: en-US
Content-Type: application/json;charset=UTF-8
Date: Wed, 22 Jun 2016 04:48:44 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Pragma: no-cache
Server: nginx
Set-Cookie: JSESSIONID=5E201976C7F368884C38807FC00722C7; Path=/taocaimall/; HttpOnly
Content-Length: 483
Connection: Close
 
'''
posted @ 2017-02-20 14:53  帅的不敢上厕所  阅读(760)  评论(0编辑  收藏  举报