import urllib
from requests_oauthlib import OAuth1
import requests
import sys
def main():
#API private key
CK = 'your key' #Consumer key
CKS = 'your key' #Consumer secret
AT = 'your key' #Access token
ATS = 'your key' #Access token secret
tweets = get_trend(CK, CKS, AT, ATS,)
#Display search results
print(tweets[0:3])
def get_trend(CK, CKS, AT, ATS,):
#request
url = "https://api.twitter.com/1.1/trends/place.json?id=23424856"
auth = OAuth1(CK, CKS, AT, ATS)
response = requests.get(url, auth=auth)
data = response.json()[0]['trends']
return data
if __name__ == '__main__':
main()
Recommended Posts