0
import facebook
from datetime import datetime
import time
TIME = datetime.now().strftime
while(1):
STARTINGMIN = 0
STARTINGSEC = 0
STARTINGMIN = TIME("%M")
STARTINGSEC = TIME("%S")
print("Preparing API, Functions, and tokens... Current Time : " + TIME("%H:%M:%S"))
def checklink(link):
links = open("C:\\Users\\BEALL619\\Desktop\\Python\\FACEBOOKPAGEBOT\\usedlinks.txt")
for CHECKING in links.readlines():
CHECKING = CHECKING.rstrip('\n')
print("New link - " + link + " Compared to used link - " + CHECKING)
if str(link) == str(CHECKING):
print("[!] Duplicate link found")
linkstat = "BAD"
break
elif(not link == CHECKING):
print("[*] This is not duplicated... So Far")
print("Link is not duplicated. Preparing to post")
linkstat = "GOOD"
return(linkstat)
"""
cfg = {
"page_id" : "i am not",
"access_token" : "dumb enough to",
"appsecret_proof" : "leave these values in the code"
}
def get_api(cfg):
graph = facebook.GraphAPI(cfg['access_token'])
resp = graph.get_object('me/accounts')
page_access_token = None
for page in resp['data']:
if page['id'] == cfg['page_id']:
page_access_token = page['access_token']
graph = facebook.GraphAPI(page_access_token)
return graph
api = get_api(cfg)
def post(link):
attach = {
"link":link,
}
status = api.put_wall_post(attachment=attach, message = "")
"""
print("Done Preparing API, Functions, And Tokens. Took - " + str(int(TIME("%M")) - int(STARTINGMIN)) + "M " + str(int(TIME("%S")) - int(STARTINGSEC)) + "S")
STARTINGMIN = 0
STARTINGSEC = 0
while(not(TIME("%H") == "00" and TIME("%M") == "00" or TIME("%H") == "02" and TIME("%M") == "00" or TIME("%H") == "04" and TIME("%M") == "00" or TIME("%H") == "06" and TIME("%M") == "00") or TIME("%H") == "08" and TIME("%M") == "00" or TIME("%H") == "10" and TIME("%M") == "00" or TIME("%H") == "12" and TIME("%M") == "00" or TIME("%H") == "14" and TIME("%M") == "00" or TIME("%H") == "16" and TIME("%M") == "00" or TIME("%H") == "18" and TIME("%M") == "00" or TIME("%H") == "20" and TIME("%M") == "00" or TIME("%H") == "22" and TIME("%M") == "00"):
time.sleep(.2)
print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
不顾一切,但问题的strftime不会里面更新..我凌乱的程序员(这个剧本不这样做又.. obvisouly)datetime.now()。while循环
行print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
打印同样的事情...我需要用它打印正确
同时键入这个问题,我知道无助于问题可能是TIME = datetime.now().strftime
编辑
我之所以认为我所做的工作是因为我个人习惯于从变量调用函数。
我从这个问题我所犯的错误是我不小心存放在变量,而不是“半函数值”得到的帮助后(如果是有道理的)
内环路你在哪里试图更新时间 –
我想我知道你在暗示什么.. 我应该只是datetime.now更换时间无处不在的代码()。STRFTIME – Beall619
所以我想不会,监守你想每次通过循环检入一次,而不是继续打勾。可能有意义的是,在循环外部设置startTime并使用它来设置起始值,然后取出TIME = statemnent并将其设置为while循环内的第一行。 –