diff options
author | carp <25677564+carp@users.noreply.github.com> | 2020-07-13 13:29:50 -0400 |
---|---|---|
committer | carp <25677564+carp@users.noreply.github.com> | 2020-07-13 13:29:50 -0400 |
commit | 3e7c2e260384a3e381f01717fd71a694b71cae6e (patch) | |
tree | 2e6a14546026baea5ef1b6267a30a3a2acd3d1e2 /provision.py | |
parent | d843c598deb492a53303cb18a0746584b6723dbf (diff) | |
download | yaoi-communism-3e7c2e260384a3e381f01717fd71a694b71cae6e.tar.gz yaoi-communism-3e7c2e260384a3e381f01717fd71a694b71cae6e.zip |
code format
Diffstat (limited to 'provision.py')
-rw-r--r-- | provision.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/provision.py b/provision.py index b995267..6c97a3c 100644 --- a/provision.py +++ b/provision.py @@ -2,19 +2,21 @@ import pandas import os
import ast
import twint
-import requests
+import requests
+
def download(url):
- filename = url.split('/')[-1]
+ filename = url.split("/")[-1]
r = requests.get(url, allow_redirects=True)
- with open("pics/"+filename, 'wb') as f:
+ 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.Images = True
c.Store_csv = True
c.Output = "yuribot.csv"
twint.run.Search(c)
@@ -22,14 +24,10 @@ 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])
+ 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 +df["photos"].apply(lambda x: download(ast.literal_eval(x)[0]))
|