Created
January 14, 2020 04:51
-
-
Save rishi-a/dcf264d6a1f3e26ad353a16c97938279 to your computer and use it in GitHub Desktop.
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 twitter | |
api = twitter.Api(consumer_key='', | |
consumer_secret='', | |
access_token_key='', | |
access_token_secret='') | |
#create the extra columns | |
t['createdOn'] = None | |
t['isVerified'] = None | |
t['Geo'] = None | |
#main task of fillling up tables | |
for i in range(len(t)): | |
#print("Iteration = ", i) | |
if t.loc[i, "username"] not in users: | |
if (t.loc[i, "Geo"] == None) or (t.loc[i, "isVerified"] == None): | |
try: | |
u = api.GetUser(screen_name=t.loc[i, "username"]) | |
t.loc[i, "Geo"] = u.location | |
t.loc[i,"CreatedOn"] = u.created_at | |
t.loc[i, "isVerified"] = u.verified | |
requestNo = requestNo + 1 | |
users.append(t.loc[i, "username"]) | |
except Exception as e: | |
print("Faulty Iteration = ", i) | |
if (e.message[0]['code'] != 50) and (e.message[0]['code'] != 63): | |
print(e.message[0]) | |
print("Sleeping . .") | |
time.sleep(900) | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment