DEV Community

Cover image for Sentiment analysis on Trump's tweets using Python 🐍
Rodolfo Ferro
Rodolfo Ferro

Posted on • Edited on

Sentiment analysis on Trump's tweets using Python 🐍

Latest comments (97)

Collapse
 
microworlds profile image
Caleb David

Great article. You can also use this tool (link below) to search for live or historical tweets

rapidapi.com/microworlds/api/twitt...

Collapse
 
joeyjoeyjoeey profile image
joeyjoeyjoeey

Where is the code for this located? Am I missing something?

Collapse
 
boardmain profile image
samuele coppede

where is the tutorial?

Collapse
 
rodolfoferro profile image
Rodolfo Ferro

Wow, I've just realized that it has been deleted. 😥
Anyway, you can find it in here: rodolfoferro.xyz/sentiment-analysi...

Collapse
 
eithbot profile image
eith-bot

I can't have an access to API since 3 weeks ago. They didn't gave me un authorisation so what can I do? I should start my research about covid 19 using syntement analysis approach

Collapse
 
adityadeswal profile image
adityadeswal

Where is the tutorial???

Collapse
 
tommypratama profile image
Tommy Pratama

Where the tutorial?

Collapse
 
vishnupriyats1 profile image
Vishnupriya T S

Awesome tutorial. Can you please tell me,how can i retrieve today's tweets.

Collapse
 
mwanjajoel profile image
mwanjajoel

Ahhh nice, thanks a lot

Collapse
 
aminabahri4 profile image
amina bahri

plz how can i extract arabic data i try this code but no result
import tweepy
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener

class Listener(StreamListener):
def on_data(self, data):
file = open("twee.txt", "a")
file.write(data + "\n")
file.close()
print("Record saved")

def on_error(self, status):
    print(status)

auth = OAuthHandler("", "")
auth.set_access_token("","")

tweets = tweepy.Cursor(tweepy.api.search, lang= "Ar").items()

Stream = Stream(auth, Listener())
Stream.filter(track = ["informatique"])

Collapse
 
rah_kaushik profile image
Rahul Kaushik • Edited

Hi Rodolfo, Thanks a lot for a very comprehensive tutorial. However, I still could not get rid of the credentials import problem

ModuleNotFoundError: No module named 'credentials'

I saw in the discussion that you have mentioned a solution but I am very new to Pytho. So I still could not figuer out the solution. Can you please discribe how the file credentials.py should look like (offcourse leaving the blank space where I can put my own credentials)? Thanks a lot.

Collapse
 
rah_kaushik profile image
Rahul Kaushik

Hi Rodolfo, I figuered out the solution and your code worked like a charm. Its awesome.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.