I am new to Python and programing in general.
I wrote this script and it runs with out error but is doesn't print any content in the .csv even though I know there is content to print. I have been stuck for a day or 2 and need some help.
import sys
import json
import urllib
import oauth2 as oauth
import requests
import time
import csv
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_KEY = ""
ACCESS_SECRET = ""
consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
access_token = oauth.Token(key=ACCESS_KEY, secret=ACCESS_SECRET)
client = oauth.Client(consumer, access_token)
html ="https://api.twitter.com/1.1/search/tweets.json?q=@gmail.com"
response, data = client.request(html)
f = open("twitter_gmail.csv", 'a')
handle_tweet =json.loads(data)
def handle_tweet(self, data):
search_terms = ['@gmail.com']
text = message.get('text')
words = text.split()
matches = []
for term in search_terms:
match = [word for word in words if term in word]
matches.append(match)
f.write('%s,%s,%s,%s\n' % (message.get('created_at'), message.get('text'), message.get('user').get('id'),matches))