| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1459 人关注过本帖
标题:帮忙看下代码哪儿出了问题
只看楼主 加入收藏
弎弍
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-8-3
收藏
 问题点数:0 回复次数:0 
帮忙看下代码哪儿出了问题
程序代码:
#coding:utf-8

import time

from selenium import webdriver

from selenium. import Keys

import os,random,re

import urllib

import get_cphao

def get3qihao_old(now_qishu): #取近3期的旧版本

#返回近3期组六

list3=[]

x=get_cphao.getbyqi(str(int(now_qishu)-1))

y=get_cphao.getbyqi(str(int(now_qishu)-2))

z=get_cphao.getbyqi(str(int(now_qishu)-3))

print x,y,z

for z6 in [x,y,z]:

if z6!=None:

list3.append("".join(sorted(z6)))

else:

continue

return list3

def get3qihao(now_qishu):

url='http://fx.'

page = urllib.urlopen(url)

sc=page.read()

for a in range(int(now_qishu),int(now_qishu)-3,-1):

print str(a)+''

a=str(int(a)-1)

reg = str(a)+r'.*\n.*</i></td>*'

imgre1 = (reg)

b= re.findall(imgre1,sc)

# print "b",b

if len(b)!=0:
c= "".join(b).split('</i><i class="ml6 i-ball i-b20_1">') #['170624040 <b class="fw400 cred">12:41</b></span></td>\r\n\t\t\t\t<td><i class="ml6 i-ball i-b20_1">5', '3', '9', '2', '7</i></td>']

# print "c",c

if len(c)!=0:

print c[2]+c[3]+c[4][0]

hao=str(c[2]+c[3]+c[4][0])

list3.append("".join(sorted(hao)))

print list3

def Proceed(dic):

sy=0

cb=0

# dic={u'170624072': 0.64, u'170624080': 0.64, u'170624083': 0.64, u'170624082': 0.64, u'170624085': 0.64, u'170624084': 0.64, u'170624086': 0.64}

for k,v in dic.items():

# print get_cphao.getbyqi(k)

temp=get_cphao.getbyqi(k)

if temp!=None:

# temp=get_cphao.getbyqi(k)

a= "".join(sorted(temp))

if a in haoma:

sy+=dic[k]*2.5

cb+=dic[k]

print "有NONE"

return (sy-cb)

znum=0

current_qihao=0

list_z3=[] #最近3期情况

touru=0

shouyi=0

beishu=0

cp_data={} #期号投入情况,便于计算收益

def firstcp():

file1=open(r'D:/Downloads/cp_log.txt','a+')

time.sleep(5)

try:

now_qishu=b.find_element_by_xpath('//*[@id="current_issue"]').text

except:

time.sleep(10)

print u"停顿10秒后找当期号!"

b.find_element_by_xpath('//*[@id="tabbar-div-s2"]/span[3]/span[2]').click()

print "find it"

print u"当前期数:%s"%now_qishu

# get3qihao(now_qishu) 这里会输出一次

global znum

global current_qihao #用作外部判断用

global list_z3

global touru

global shouyi

current_qihao=now_qishu

zhongjiangcishu=0

global beishu

for hm in get3qihao(now_qishu):

if hm in haoma:

zhongjiangcishu+=1 #最近3期的中奖次数

znum+=1

print u"全计划已中:%s次"%znum

print "最近3期中 %s次"%zhongjiangcishu

list_z3.append(zhongjiangcishu)

beishu='5'

if len(list_z3)>=5 and (list_z3[-5:].count(0)==5): #列表里至少有4个记录,并且最近3记录都是0情况

beishu=random.randint(8,15)

print beishu

b.find_element_by_xpath('//*[@id="tabbar-div-s2"]/span[3]/span[2]').click() #后三

time.sleep(2)

b.find_element_by_xpath('//*[@id="smalllabel_1_3"]').click()

print "test"

if zhongjiangcishu<=0:

b.find_element_by_xpath('//*[@id="lt_write_box"]').send_keys(haoma)

b.find_element_by_xpath('//*[@id="choosemodes"]/span[4]').click() #厘模式

b.find_element_by_xpath('//*[@id="lt_sel_dyprize"]/option[2]').click() #超级返奖

b.find_element_by_xpath('//*[@id="lt_sel_times"]').clear()

b.find_element_by_xpath('//*[@id="lt_sel_times"]').send_keys(str(beishu)) #倍模式

touru=int(beishu)*0.128

cp_data[current_qihao]=touru

time.sleep(1)

b.find_element_by_xpath('//*[@id="lt_sel_insert"]').click() #添加

b.find_element_by_xpath('//*[@id="lt_buy"]').click()

time.sleep(3)

b.find_element_by_xpath('//*[@id="confirm_yes"]').click()

file1.write("%s 期投注:"%str(current_qihao) +' ')

file1.write("%s 倍数"%str(beishu)+'\n')

b.find_element_by_xpath('//*[@id="alert_close_button"]').click()

print "close"

file1.close()

test_randome=random.randint(1,9)

if (zhongjiangcishu==1) and (test_randome>=5): #对近3期中1加入50%随机

b.find_element_by_xpath('//*[@id="lt_sel_times"]').send_keys('4') #倍模式

file1.write("5:倍数 近3期==1 "+'\n')

print "本轮放弃,不投注",current_qihao

b=webdriver.Chrome()

b.set_window_position(-500,0)

b.implicitly_wait(30)

b.get('http://game.')

b.maximize_window()

b.find_element_by_xpath('//*[@id="username"]').send_keys('username')

time.sleep(30)

print "ha ha ha where's the money ?"

print "****************************************"

print "begin the game! show me the money !"

print b.title

num=0

haoma='013,014,016,017,019,023,025,026,028,' \

'029,034,035,036,037,038,039,046,047,049,' \

'056,058,059,067,068,069,079,089,134,136,137,139,' \

'146,149,167,169,179,235,236,238,239,256,259,268,' \

'269,289,346,347,349,356,358,359,367,368,369,379,' \

b.switch_to_frame('leftframe')

print b.find_element_by_xpath('//*[@id="usermoney"]').text

b.find_element_by_xpath('//*[@id="leftcon"]/div[3]/div/a[1]').click() #重庆

time.sleep(4)

b.switch_to.default_content() #google

# b._switch_to.parent_frame() #ie

time.sleep(0.5)

b.switch_to_frame('mainframe')

print " ready go!!! "

b.find_element_by_xpath('//*[@id="lt_sel_dyprize"]/option[2]').click()

for i in range(100):

print "这是第 %s 次 运行:"%num

last_id=current_qihao

print "lastid :",last_id

# firstcp()

print u"前倍数:",beishu

firstcp()

except Exception as msg:

print msg

print u"后倍数:",beishu

print cp_data

count=0

ctime=100

ncount=ctime-count

print "current:",current_qihao

# print int(current_qihao)-int(last_id)

while(int(current_qihao)<=int(last_id)):

# ncount=ctime-count

print "||---"+"倒计时"+"----|| " ,ncount

time.sleep(10) #10秒后再检测期数

ncount=ncount-1

if ncount<50:

b.refresh()

b.find_element_by_xpath('//*[@id="leftcon"]/div[3]/div/a[1]').click()

b.switch_to.default_content()

current_qihao=b.find_element_by_xpath('//*[@id="current_issue"]').text

print "******current:",current_qihao

print "获取开奖期号失败..."

print "已刷新"

print "上期投注时间结束,等待开奖,正在销售 %s 期:"%str(current_qihao)

time.sleep(180)

num+=1

if znum>=100:

print "over"

exit(0)

print "num=**************************************** ",num

if num%5==0:

file2=open(r'D:/Downloads/cp_log.txt','a+')

print "cp_data:-----:",cp_data

if cp_data!=None:

value=Proceed(cp_data)

print "*******当前收益*********:",value

file2.write("*******当前收益********* %s:"%value+'\n')

file2.close()

if value>=10.0:

print "收益达到预期,结束"

b.quit()
搜索更多相关主题的帖子: time str print if click 
2018-08-03 21:36
快速回复:帮忙看下代码哪儿出了问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.315730 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved