Last active
September 5, 2019 07:50
-
-
Save lmacchiavelli/e7504f579981d1bf96565147589a5a46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Importiamo le librerie | |
import os | |
from InstagramAPI import InstagramAPI | |
import time | |
import schedule | |
#Importo l'elenco dei file presenti nella cartella coda_file in una lista | |
foldername = './coda_file/' | |
fileNames = os.listdir(foldername) | |
def pubblica(): | |
#definiamo la funzione per gestire il collegamento all'api e la pubblicazione dei post | |
print("..Pubblicazione") | |
IGUSER = '...Il tuo username di In' | |
PASSWD = '...la tua password' | |
IGCaption = 'Questa è la descrizione della nostra immagine posso aggiungere anche dei tag #motivazione #dailymotivational...' | |
igapi = InstagramAPI(IGUSER, PASSWD) | |
#Mi collego all'API di instagram | |
igapi.login() | |
#Pubblico l'immagine | |
photo = foldername'+ fileNames[0] | |
igapi.uploadPhoto(photo, caption=IGCaption, upload_id=None) | |
#Elimino la foto pubblicata | |
print("Elimino : " + foldername + fileNames[0]) | |
os.remove(foldername + fileNames[0]) | |
#Temporizzo l'operazione con il modulo schedule | |
schedule.every().day.at("09:12").do(pubblica) | |
while True: | |
schedule.run_pending() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment