Use twitter API to get the number of tweets related to a certain keyword

Caution

** You can only get up to 100 items at a time, so if you have 100 or more items, you have to retake the next page or ** ~~ obediently use the Streaming API. .. .. ~~ ** User Streams API will be discontinued on June 20, 2018 ** http://www.itmedia.co.jp/news/articles/1712/20/news101.html

Premise

--I want to get the number of tweets related to a certain keyword using twitter API --Implementation assumes python

Overview

-~~ There is a REST API for searching, so it seems easiest to hit it regularly ~~ --API limit is 450req / 15min. You can get up to about 40,000 keywords if you update once a day. --If you want to use more frequency and keywords, consider using Streaming API.

Use REST API

You can get it by using https://api.twitter.com/1.1/search/tweets.json

Official API Reference https://dev.twitter.com/rest/public/search https://dev.twitter.com/rest/reference/get/search/tweets

Japanese materials https://syncer.jp/twitter-api-matome/get/search/tweets

-$ .search_metadata.count is the number of searches ―― ~~ You can specify the period, and you can get it retroactively ~~ (up to 1 week) --Limited to 450 requests per 15 minutes --Authentication is OAuth

About the number of keywords that can be acquired

-~~ Simply put, you can get 450 keywords in 15-minute units ~~ -~~ If the acquisition frequency is good on a daily basis, it is possible to acquire the number of keyword searches of 1000 keywords or more (maximum 450 * ((60 * 24) / 15) = 43200 requests) ~~ -~~ For past minutes, it is also possible to specify a longer specified period and count the number by yourself without using search_metadata.count of the response ~~ --You can use this if the number of tweets is 100 or less, but you can't get 100 or more keywords without re-searching the next page.

Search Twitter using Python --Qiita http://qiita.com/mima_ita/items/ba59a18440790b12d97e

How to get in python

There seem to be some libraries for twitter, but it seems simpler to implement by yourself using only the OAuth library.

Get a large amount of Starbucks Twitter data with python and try data analysis Part 1 http://qiita.com/kenmatsu4/items/23768cbe32fe381d54a2

Access the Twitter API in Python http://qiita.com/yubais/items/dd143fe608ccad8e9f85

~~ Use Streams API ~~

User Streams API will be deprecated on June 20, 2018 http://www.itmedia.co.jp/news/articles/1712/20/news101.html

If you want a lot of real-time data, you can use the Steaming API to get all the current tweets.

--Since sampled data can be used in a general account, the correct number cannot be obtained. --Past data cannot be obtained --Since the amount of data is large, it seems a little more difficult to handle than the REST API.

reference

Keep getting tweets containing specific keywords using Streaming API in Python --Qiita http://qiita.com/mima_ita/items/ecdf7de2fe619378beee

A note about the Twitter Streaming API http://lealog.hateblo.jp/entry/2013/03/10/100845

Recommended Posts

Use twitter API to get the number of tweets related to a certain keyword
Get a lot of Twitter tweets at once
Use the MediaWiki API to get Wiki information
Try to estimate the number of likes on Twitter
Get the number of digits
Use API to mark a large number of unread emails in Gmail as read
Use Twitter API to reduce the time taken by Twitter (create a highlighting (like) timeline)
Get the number of specific elements in a python list
Try to improve the accuracy of Twitter like number estimation
Get the number of views of Qiita
Get the number of Youtube subscribers
Get the number of PVs of Qiita articles you posted with API
How to get the vertex coordinates of a feature in ArcPy
Create a function to get the contents of the database in Go
Get the number of readers of a treatise on Mendeley in Python
[Twitter] I want to make the downloaded past tweets (of my account) into a beautiful CSV
From the introduction of GoogleCloudPlatform Natural Language API to how to use it
Use shutil to delete all folders with a small number of files
[For beginners] I want to get the index of an element that satisfies a certain conditional expression
Get the number of searches with a regular expression. SeleniumBasic VBA Python
[Python] A program that calculates the number of socks to be paired
Various methods to numerically create the inverse function of a certain function Introduction
Get the minutes of the Diet via API
[Linux] Command to get a list of commands executed in the past
4 methods to count the number of occurrences of integers in a certain interval (including imos method) [Python implementation]
I tried to get the authentication code of Qiita API with Python.
Sample code to get the Twitter API oauth_token and oauth_token_secret in Python 2.7
Get the number of articles accessed and likes with Qiita API + Python
Get the filename of a directory (glob)
I tried to get the movie information of TMDb API with Python
How to play a video while watching the number of frames (Mac)
How to use the Slack API using Python to delete messages that have passed a certain period of time for a specific user on a specific channel
I wanted to know the number of lines in multiple files, so I tried to get it with a command
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
Use the Java SDK of GoogleMapsAPI to get the result of reverse GeoCoding in Japanese.
Find out how to divide a file with a certain number of lines evenly
[NNabla] How to get the output (variable) of the middle layer of a pre-built network
How to count the number of elements in Django and output to a template
Python script to get a list of input examples for the AtCoder contest
The format of the message obtained by Slack API is subtly difficult to use
How to make a Raspberry Pi that speaks the tweets of the specified user
Create a filter to get an Access Token in the Graph API (Flask)
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
How to calculate the volatility of a brand
Upload a large number of images to Wordpress
Get the caller of a function in Python
I tried to touch the API of ebay
Find the number of days in a month
How to use the NHK program guide API
Use the Kaggle API inside a Docker container
To get the path of the currently running python.exe
Use pygogo to get the log in json.
Create a command to get the work log
After hitting the Qiita API with Python to get a list of articles for beginners, we will visit the god articles
Various methods to numerically create the inverse function of a certain function Part 1 Polynomial regression
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
How to identify the element with the smallest number of characters in a Python list?
A script that can perform stress tests according to the number of CPU cores
A story about a Python beginner trying to get Google search results using the API
Find a guideline for the number of processes / threads to set in the application server