![]() |
Twitter listen script, dynamic search value? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Twitter listen script, dynamic search value? (/thread-13802.html) |
Twitter listen script, dynamic search value? - quitte74 - Nov-01-2018 Hi guys, I have the below "Twitter listen" Python script running on my Raspberry Pi. When it is running it is simply listening for tweets from a specific user based on the Id. But I need to change that Id dynamic (look at the last code line), maybe from the "def on_success"!? But how do I do that? Any help will be appreciated. # coding=utf-8 #!/usr/bin/env python import os import sys import requests import time import datetime from os import path from twython import TwythonStreamer from auth import ( consumer_key, consumer_secret, access_token, access_token_secret ) from twython import Twython class MyStreamer(TwythonStreamer): print("starting") #print(DATABASE_URL) def on_success(self, data): if 'text' in data: #get handleID from tweet userid = data['user']['id_str'] stream = MyStreamer( consumer_key, consumer_secret, access_token, access_token_secret ) twitter = Twython( consumer_key, consumer_secret, access_token, access_token_secret ) stream.statuses.filter(follow='123456789') #This should be dynamic = userid |