在 Twython 搜索中使用选定数量的关注者打印每个用户,如果他们的句柄以某个字母开头

问题描述

我编写了一个脚本来列出我使用 twitter.search 进行的搜索中的所有用户,并打印具有特定关注者数量的所有用户,在本例中为 2。如果用户句柄以特定字母开头,我也在寻找它来打印它。在这种情况下,字母是 s

这是我的代码

from twython import Twython
import twython

words = ["space","faa"]
keywords = " OR ".join(words)

twitter = Twython("","","")


search_results = twitter.search(q=keywords,count=10)
try:
    for tweet in search_results["statuses"]:
        try:
            st=tweet["entities"]["user_mentions"]
            if st != []:
            if twitter.show_user(screen_name=st[0]["screen_name"])['followers_count'] == 2:
                if str(twitter.show_user(st[0]["screen_name"])).startswith("s") == True:
                    print(st[0]["screen_name"])
                
        except twython.TwythonError as e:
            print(e)
except twython.TwythonError as e:
    print(e)

但是在运行程序时,它立即结束,日志中没有任何内容被打印。我做错了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)