import urllib
from requests_oauthlib import OAuth1
import requests
import sys
def main():
# APIの秘密鍵
CK = 'your key' # コンシューマーキー
CKS = 'your key' # コンシューマーシークレット
AT = 'your key' # アクセストークン
ATS = 'your key' # アクセストークンシークレット
tweets = get_trend(CK, CKS, AT, ATS,)
# 検索結果を表示
print(tweets[0:3])
def get_trend(CK, CKS, AT, ATS,):
# リクエスト
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()
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme