From e78f351e06e432a607ebadc8de3ea6d27315c088 Mon Sep 17 00:00:00 2001 From: carp <25677564+carp@users.noreply.github.com> Date: Mon, 13 Jul 2020 13:27:04 -0400 Subject: git init --- provision.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 provision.py (limited to 'provision.py') diff --git a/provision.py b/provision.py new file mode 100644 index 0000000..b995267 --- /dev/null +++ b/provision.py @@ -0,0 +1,35 @@ +import pandas +import os +import ast +import twint +import requests + +def download(url): + filename = url.split('/')[-1] + r = requests.get(url, allow_redirects=True) + with open("pics/"+filename, 'wb') as f: + f.write(r.content) + +# archive @AceYuriBot for images/sources + +c = twint.Config() +c.Username = "AceYuriBot" +c.Images = True +c.Store_csv = True +c.Output = "yuribot.csv" +twint.run.Search(c) + +os.makedirs("pics", exist_ok=True) +df = pandas.read_csv("yuribot.csv") +source = ( + df["urls"] + .apply(lambda x: ast.literal_eval(x)) + .apply(lambda x: x[0] if x else None) +) +file_location = df["photos"].apply( + lambda x: os.path.basename(ast.literal_eval(x)[0]) +) +# save to file where bot will pull data from +pandas.concat([source, file_location], axis=1).to_csv("files.csv") +# download images +df["photos"].apply(lambda x: download(ast.literal_eval(x)[0])) \ No newline at end of file -- cgit v1.2.3