#!/usr/bin/python    
#-*-coding:utf-8-*-    
#  
# 触发公会战逻辑, 每天晚上 6点-7点 1分钟触发一次
#    
import httplib,urllib,time;  #加载模块    
def trigger(zoneid):  
    #定义需要进行发送的数据    
    params = urllib.urlencode({'id':'34','name':'jgao'});     
    #定义一些文件头    
    headers = {"Content-Type":"application/x-www-form-urlencoded","Connection":"Keep-Alive","Referer":"http://115.159.17.67/PetMulti/Gameserver/Amfphp/Triggers/GuildFightTrigger.php?action=newnew"};
    headers = {"Content-Type":"application/x-www-form-urlencoded","Connection":"Keep-Alive","Referer":"http://192.168.10.27/PetMulti/Gameserver/Amfphp/Triggers/GuildFightTrigger.php?action=newnew"};
    #与网站构建一个连接    
    conn = httplib.HTTPConnection("115.159.17.67");
    conn = httplib.HTTPConnection("192.168.10.16");
    #开始进行数据提交   同时也可以使用get进行    
    conn.request(method="POST",url="/PetMulti/Gameserver/Amfphp/Triggers/GuildFightTrigger.php?zoneid="+zoneid,body=params,headers=headers);     
    #返回处理后的数据    
    response = conn.getresponse();     
    #判断是否提交成功    
    if response.status == 200:
        print ("zone "+ zoneid +"succeed!");
        print response.read();
    else:     
        print ("fail!");
    #关闭连接    
    conn.close();

if __name__=='__main__':
    loop = 1
    while loop <= 30:
        trigger('1')
        #trigger('2')
        #trigger('3')
        #trigger('4')
        trigger('5')
        #trigger('999')
        loop = loop + 1
        time.sleep(60)
