3

I'm absolutely new to Stack Overflow and fairly new to Python. After downloading Tweepy and using its basic function of searching keywords, I wanted to expand and search for only geotagged tweets based on a certain geographic location. I've found several script examples but haven't had success getting them to work. My question to you all would be, Do you see any problems with the syntax of the script included? For some reason, I just cannot get it to work. I continually get an error on the print statement "print tweet.id." Thanks in advance!

from __future__ import absolute_import, print_function
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import tweepy


consumer_key="###########################"
consumer_secret="###############################"


access_token="#######################################"
access_token_secret="###################################"


def searchTweets():
    #39.95556,-75.164,4mi = Phillaelphia Location with a 4 miles radius
    tweet = api.search(q="",geocode="39.95256,-75.164,4mi",count=25)

    for tweet in tweets:
  
        if tweet.geo:  
            print tweet.id
            print tweet.geo
            print tweet.text 

class Listener(tweepy.StreamListener):
    def on_status(self,status):

        print “screen_name=’%s’ tweet=’%s’  text=’%s’” (status.author.screen_name, status.coordinates, status.text)

streaming_api = tweepy.streaming.Stream(auth, Listener(), timeout=60)
# Phillaelphia Location 
streaming_api.filter(follow=None, locations=[-75.4043,39.896,-75.0503,40.161])
RF1991
  • 2,037
  • 4
  • 8
  • 17
F. Wagner
  • 31
  • 2

0 Answers0