def update_groups(): gruposRef = Firebase(FIREBASE_BASE_URL+'groups') gruposRef.delete(); results = json.load(urllib.urlopen(API_BASE_URL+"group/")) for grupo in results['objects']: grupoRef = Firebase(FIREBASE_BASE_URL+'groups/'+str(grupo['id'])) grupoRef.set(grupo)
# coding=UTF-8 import datetime import requests from firebase import Firebase f = Firebase('https://oildata2.firebaseio.com/datas/predict') res = requests.get("http://www.taiwanoil.org/") source = res.text tmp1 = source.split("</td></tr>") nextweek_price = [] for col in tmp1 : if "<td style='text-align:right;'>" in col : tmp2 = col.split("<td style='text-align:right;'>",-1)[-1] nextweek_price[len(nextweek_price):] = [tmp2] nextweek_98 = nextweek_price[1] nextweek_95 = nextweek_price[2] nextweek_92 = nextweek_price[3] nextweek_ultra = nextweek_price[4] #print "--- next week ---" print "98 : " + nextweek_98 print "95 : " + nextweek_95 print "92 : " + nextweek_92 print "ultra : " + nextweek_ultra ##r = f.push({'ninetwo':float(nextweek_92),'ninefive':float(nextweek_95),'nineeight':float(nextweek_98),'ultra':float(nextweek_ultra)}) r = f.delete(); r = f.push({'ninetwo':float(nextweek_92),'ninefive':float(nextweek_95),'nineeight':float(nextweek_98),'ultra':float(nextweek_ultra)})
>要素を削除する :d """) submode = input('>> ') if submode == 'a': print('\n追加したいフラグ名を入力して下さい') key = input('>> ') firebase.update({key: 0}, 'data/flag') elif submode == 'd': print('\n削除したいフラグ名を入力して下さい') key = input('>> ') firebase.delete(key, "data/flag") else: print('入力された文字に間違いがあります') #メッセージ操作 elif mode == 'm': print(get_data("message")) print(""" >要素を追加,変更する :a >要素を削除する :d """) submode = input('>> ')