Skip to content

Commit 7269ae6

Browse files
authored
Merge pull request Python-World#348 from AnilKumarTeegala/Fetch_and_store_tweets
Added README file to Fetch and store tweets
2 parents 59006cb + d34fcf4 commit 7269ae6

21 files changed

Lines changed: 92 additions & 3 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Fetch and Store Tweets
2+
This python script is used to fetch the required number of tweets of a particular Hashtag through your twitter account and generates an `.csv` file.
3+
4+
## Prerequisites
5+
6+
1. You need any Python IDE to run this script. You can visit [here](https://www.python.org/downloads/) to download the latest version of Python based on your operating System.
7+
8+
2. Next to execute this script you have to get the API keys from twitter developer account by creating an app at [Twitter developer account](https://developer.twitter.com/apps). For creating an app at [Twitter developer account](https://developer.twitter.com/apps) you have to follow the below steps
9+
10+
### Step1:
11+
12+
Visit [Twitter Developer Account Website](https://developer.twitter.com/apps) and click on Create app as shown below
13+
14+
<img src="img/step-1.png" alt="step-1" style="zoom:33%;" />
15+
16+
### Step2:
17+
18+
Click on Apply
19+
20+
<img src="img/step-2.png" alt="step-2" style="zoom: 50%;" />
21+
22+
### Step3:
23+
24+
Based on your choice select the Reason for using twitter developer tools and Click on Next
25+
26+
<img src="img/step-3.png" alt="step-3" style="zoom:33%;" />
27+
28+
### Step4:
29+
30+
Enter your country and what you would you call and Click on Next
31+
32+
<img src="img/step-4.png" alt="step-4" style="zoom:33%;" />
33+
34+
### Step5:
35+
36+
Now Carefully read the questions and answer all the questions as per the requirement. Because based on you answer only the account approval will be taken place
37+
38+
<img src="img/step-5.png" alt="step-5" style="zoom:33%;" />
39+
40+
### Step6:
41+
42+
If your account successfully approved you can come to homepage [Twitter developer account](https://developer.twitter.com/apps) and now click on Create an app icon on the right top.
43+
44+
**Note:** sometimes it takes time to approval of the developer account based on step-5 answers
45+
46+
<img src="img/step-6.png" alt="step-6" style="zoom:33%;" />
47+
48+
### Step7:
49+
50+
Fill the require fields and click on Create
51+
52+
<img src="img/step-7.png" alt="step-7" style="zoom:33%;" />
53+
54+
### Step8:
55+
56+
After creating the App click on **Keys and tokens** option you will observe Consumer and Access token keys. Copy them and paste them in the python script
57+
58+
<img src="img/step-9.png" alt="step-8" style="zoom: 50%;" />
59+
60+
## How to run the script
61+
62+
1. Save the script in the local machine.
63+
64+
2. Update the API and Access token Keys in the Python script which generated in step8
65+
66+
3. Open a terminal/command prompt and change directory location to the folder where your script is located and run the below commands
67+
68+
1. To install required packages run the below command
69+
70+
```python
71+
pip install -r requirements.txt
72+
```
73+
74+
2. To execute the script run the following command
75+
76+
```python
77+
python fetch_store_tweet.py
78+
```
79+
80+
After successful execution of the script you should observe the below output in command prompt/terminal as well as one `.csv` file with the required number of tweets will be generated.
81+
82+
<img src="img/output.png" alt="output" style="zoom: 33%;" />
83+
84+
Final generated tweets in`.csv` file output
85+
86+
<img src="img/output-2.png" alt="output2" style="zoom: 33%;" />
87+
88+
## Author Name
89+
90+
[AnilKumarTeegala](https://github.com/AnilKumarTeegala)

projects/Fetch_and_store_tweets/fetch_store_tweet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import tweepy
22
import csv
3-
import pandas as pd
4-
####input your credentials here
3+
4+
# input your credentials here
55
consumer_key = ''
66
consumer_secret = ''
77
access_token = ''
152 KB
Loading
152 KB
Loading
160 KB
Loading
160 KB
Loading
46.2 KB
Loading
46.2 KB
Loading
30.1 KB
Loading
30.1 KB
Loading

0 commit comments

Comments
 (0)