Posté le 22 janvier 2019
Télécharger | Reposter | Largeur fixe

def index(mot, fichier): #Fonction pour rechercher un mot
fic=open(fichier, "r")
ind=fic.read().split().index(mot)
return ind







def postedStory(userId,timeValue):
         api.SendRequest('feed/user/' + str(userId) + '/reel_media/') #Requête des infos concernant les stories
         info = api.LastJson
         c0 = "data"
         c1 = str(userId)
         c2 = ".txt"
         fichier = open(c0+c1+c2,"w") #on enregistre les infos dans un fichier "dataxxxxxxx.txt" ou xxxxxxx correspond à l'id
         fichier.write(str(info))
         fichier.close()
         flag = True

         while(flag==True):
         
                  try :
                           a1 = index("u'device_timestamp':",c0+c1+c2) #On cherche le ce qui correpsond au dernier timestamp
                           fichier = open(c0+c1+c2, "r")
                           detail = fichier.read()
                           fichier.close()
                           sdetail = detail.split()
                           sdetail[a1] = ''
                           newsdetail = " ".join(sdetail)

                           fichier = open(c0+c1+c2,"w")
                           fichier.write(newsdetail)
                           fichier.close()
                  
                  except ValueError:
                           flag = False
                  


         x = sdetail[a1+1][:10]
         #print(x)


         ts = time.time()
         #print(ts)


         if((int(ts)-int(x))<timeValue):
                  out = True
         else:
                  out = False

         print(out)
         return out

x
Éditer le texte

Merci d'entrer le mot de passe que vous avez indiqué à la création du texte.

x
Télécharger le texte

Merci de choisir le format du fichier à télécharger.