Spaces:
Runtime error
Runtime error
aus10powell
commited on
Commit
•
e442e8d
1
Parent(s):
c4697f2
Update scripts/twitter_scraper.py
Browse files- scripts/twitter_scraper.py +15 -9
scripts/twitter_scraper.py
CHANGED
@@ -10,15 +10,21 @@ def get_latest_account_tweets(handle):
|
|
10 |
|
11 |
import configparser
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
24 |
auth.set_access_token(access_token, access_token_secret)
|
|
|
10 |
|
11 |
import configparser
|
12 |
|
13 |
+
import os
|
14 |
+
if os.path.exists("tweepy_auth.ini"):
|
15 |
+
config = configparser.ConfigParser()
|
16 |
+
config.read("tweepy_auth.ini")
|
17 |
+
# Get the authentication details
|
18 |
+
authentication_section = config['AUTHENTICATION']
|
19 |
+
consumer_key = authentication_section["twitter_consumer_key"]
|
20 |
+
consumer_secret = authentication_section["twitter_consumer_secret"]
|
21 |
+
access_token = authentication_section["twitter_access_token"]
|
22 |
+
access_token_secret = authentication_section["twitter_access_token_secret"]
|
23 |
+
else:
|
24 |
+
consumer_key = os.environ['twitter_consumer_key']
|
25 |
+
consumer_secret = os.environ["twitter_consumer_secret"]
|
26 |
+
access_token = os.environ["twitter_access_token"]
|
27 |
+
access_token_secret = os.environ["twitter_access_token_secret"]
|
28 |
|
29 |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
30 |
auth.set_access_token(access_token, access_token_secret)
|