Created
October 5, 2021 15:21
-
-
Save thisiskeanyvy/b812f11ca93a1ca40e757c4051bc7128 to your computer and use it in GitHub Desktop.
Instagram autopost
This file contains 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
import config | |
import urllib.request | |
from datetime import date | |
from instabot import Bot | |
#variables | |
today = date.today(); | |
bot = Bot() | |
bot.login(username = "yourusername", password = "yourpassword"); | |
def program(): | |
init(); | |
nbjours(); | |
datetime(); | |
comptenbjours(); | |
post(); | |
end(); | |
def init(): | |
print(""" | |
InstaPost par Keany Vy KHUN | |
"""); | |
def nbjours(): | |
global nbjours | |
readfile = open("jours.txt", "r+"); | |
nbjours = int(float(readfile.readline())); | |
readfile.close(); | |
def comptenbjours(): | |
ajoutdejours = nbjours + 1; | |
compteurnbjours = str(ajoutdejours); | |
file = open("jours.txt", "w+"); | |
file.write(compteurnbjours); | |
file.close(); | |
def datetime(): | |
global time | |
time = today.strftime("%d %b %Y"); | |
def post(): | |
nameimage = today.strftime("%d%b%Y"); | |
readfile = open("jours.txt", "r+"); | |
url = 'https://source.unsplash.com/1080x1080/?architecture,art,monument' | |
urllib.request.urlretrieve(url, 'posts/'+ nameimage +'.jpg') | |
bot.upload_photo("posts/"+ nameimage +".jpg", caption ="Publication journalière du : " + time + " et Jour n°"+ readfile.readline() + " du défi #daily par @thisiskeanyvy"); | |
def daily(): | |
readfile = open("daily.txt", "r+"); | |
if readfile.readline() == today.strftime("%d-%b-%Y"): | |
print(""" | |
Publication déjà éffectuée | |
"""); | |
elif readfile.readline() != today.strftime("%d-%b-%Y"): | |
program(); | |
def end(): | |
date = today.strftime("%d-%b-%Y"); | |
file = open("daily.txt", "w+"); | |
file.write(date); | |
file.close(); | |
daily(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment