-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_data_from_twitter.py
More file actions
38 lines (26 loc) · 935 Bytes
/
get_data_from_twitter.py
File metadata and controls
38 lines (26 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import tweepy
import tweepy.streaming
from tweet_refactor import insert_data
import json
import os
auth = tweepy.OAuthHandler()
auth.set_access_token()
api = tweepy.API(auth, wait_on_rate_limit=True)
class MyAnalStream(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
insert_data(status.id)
def on_error(self, error):
if error == 420:
print('smoke weed erra day')
return False
def searchUser(username):
AssholeStream = MyAnalStream()
shitStream = tweepy.Stream(auth=api.auth, listener=AssholeStream)
shitStream.filter(track=username, languages=['en'])
def searchApi(hashtags, file):
a = open('tweets.txt', 'a', encoding='cp437', errors='ignore')
for i in api.search([hashtags], languages=['en'], tweet_mode='extended'):
a.write('\n' + i.full_text)
print(i.full_text)
searchUser('olive garden')