-
Notifications
You must be signed in to change notification settings - Fork 323
/
Copy pathtwitter-user-search.py
executable file
·36 lines (29 loc) · 1.44 KB
/
twitter-user-search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
#-----------------------------------------------------------------------
# twitter-user-search
# - performs a search for users matching a certain query
#-----------------------------------------------------------------------
from twitter import *
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
import sys
sys.path.append(".")
import config
#-----------------------------------------------------------------------
# create twitter API object
#-----------------------------------------------------------------------
twitter = Twitter(auth=OAuth(config.access_key,
config.access_secret,
config.consumer_key,
config.consumer_secret))
#-----------------------------------------------------------------------
# perform a user search
# twitter API docs: https://dev.twitter.com/rest/reference/get/users/search
#-----------------------------------------------------------------------
results = twitter.users.search(q='"New Cross"')
#-----------------------------------------------------------------------
# loop through each of the users, and print their details
#-----------------------------------------------------------------------
for user in results:
print("@%s (%s): %s" % (user["screen_name"], user["name"], user["location"]))