From 38cbea07488c2ba92caad6cc88ded52cd32fd23a Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Tue, 20 Feb 2018 16:53:22 +0300 Subject: [PATCH] LIL-266. Add simple task for retrieve data by hashtag. --- apps/content/tasks.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 apps/content/tasks.py diff --git a/apps/content/tasks.py b/apps/content/tasks.py new file mode 100644 index 00000000..898266bf --- /dev/null +++ b/apps/content/tasks.py @@ -0,0 +1,19 @@ +import json +from time import sleep +from project.celery import app +from constance import config +from InstagramAPI import InstagramAPI + + +@app.task +def retrieve_photos(): + instagram = InstagramAPI( + config.INSTAGRAM_CLIENT_LOGIN, + config.INSTAGRAM_CLIENT_PASSWORD, + ) + instagram.login() + sleep(1) + if instagram.isLoggedIn and instagram.getHashtagFeed(config.INSTAGRAM_RESULTS_TAG): + with open('s.json', 'w') as f: + f.write(json.dumps(instagram.LastJson)) + return instagram.LastJson