Python Forum
Twitter listen script, dynamic search value?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Twitter listen script, dynamic search value?
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I scrape profile information from Twitter People search results? asdad 0 728 Nov-29-2022, 10:25 AM
Last Post: asdad
  Is it possible to write a python script to block twitter feeds? cubangt 0 865 Apr-07-2022, 04:14 PM
Last Post: cubangt
  Reducing JSON character count in Python for a Twitter Bot johnmitchell85 2 50,549 Apr-28-2021, 06:08 PM
Last Post: johnmitchell85
  How to listen to clipboard content change without polling the clipboard continuously? edgelord 0 2,470 Nov-27-2020, 06:07 AM
Last Post: edgelord
  Use dynamic variable from parallel running python script Sicksym 0 1,840 May-15-2020, 02:52 PM
Last Post: Sicksym
  Twitter follower network gugatcgwgf 2 2,047 May-06-2020, 10:29 AM
Last Post: gugatcgwgf
  Python script - search Apache access_log.txt for all of the JavaScript (.js) jnovak 7 4,329 May-04-2020, 07:02 AM
Last Post: snippsat
  Callback URL for twitter app Truman 5 5,385 Dec-10-2018, 10:45 PM
Last Post: nilamo
  Twitter extracts on analytics tab parthi1705 3 3,213 May-28-2018, 05:26 AM
Last Post: parthi1705
  Why is basic Twitter Connectivity So Difficult? Not sure what I'm doing wrong. Oliver 0 1,876 Mar-10-2018, 12:38 PM
Last Post: Oliver

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020