Get Twitter Trends



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

Get Twitter Trends
Get Twitter userData
[Python] Get Qiita trends
Get Twitter timeline with python
Try to analyze Twitter trends
Get celebrity tweet history from twitter
Get only image tweets on twitter
Get and visualize google search trends
Get Qiita trends with Python scraping
Get data from Twitter using Tweepy
Get delay information on Twitter and tweet
Get images by keyword search from Twitter
Get Twitter bookmarks on CentOS using Selenium
[python] Get Twitter timeline for multiple users
Program to get favorite images on Twitter
Get images from specific users on Twitter
Create a bot that boosts Twitter trends
Get a lot of Twitter tweets at once