Ejemplo n.º 1
0
def StreamTrack(loc, verbose):

    if loc in Placenames.keys():
        words = Placenames[loc]
    else:
        raise ValueError("Location not known ; How about these ones %s ?" % Placenames.keys())

    listen = Listener(arg=loc, prefix="placename", verbose=verbose)
    stream = tweepy.Stream(auth, listen)

    print "Streaming started using %s location from Placenames..." % (loc)

    stream.filter(track=words)
Ejemplo n.º 2
0
    stream = tweepy.Stream(auth, listen)

    print "Streaming started using %s location from Placenames..." % (loc)

    stream.filter(track=words)


if __name__ == "__main__":

    if sys.argv[1].split("-")[0] == "Location":
        if sys.argv[1].split("-")[1] in locationbox.keys() or sys.argv[1].split("-")[1] == "all":
            if len(sys.argv) > 2:
                verbose = True if "-v" in sys.argv[2:] else False
            else:
                verbose = False
            StreamLocation(loc=sys.argv[1].split("-")[1], verbose=verbose)
        else:
            raise KeyError("Geocode for location not known, try one of these <all> or %s" % locationbox.keys())

    elif sys.argv[1].split("-")[0] == "Track":
        if sys.argv[1].split("-")[1] in Placenames.keys():
            if len(sys.argv) > 2:
                verbose = True if "-v" in sys.argv[2:] else False
            else:
                verbose = False
            StreamTrack(loc=sys.argv[1].split("-")[1], verbose=verbose)
        else:
            raise KeyError("location not found in track dictionary, try one of these %s" % Placenames.keys())
    else:
        print "valid arguments are ex:python Streaming.py Location-Boston, python streaming.py Track-Boston"