为了账号安全,请及时绑定邮箱和手机立即绑定

在 python 中使用 Tweepy 及其跟随给定用户但不退出循环

在 python 中使用 Tweepy 及其跟随给定用户但不退出循环

拉丁的传说 2021-10-26 10:41:58
获取给定的推文 ID 并尝试关注该推文的用户。当我查看 twitter 时,我可以看到它已成功关注用户,但我的 while 循环从未退出。(这一切都在控制台中)def followUser(tweet):#Follows a user    tweet = api.get_status(tweet.id)    while tweet.user.follow_request_sent == False:        api.create_friendship(tweet.user.id)        followUser(tweet)    print("Successful follow")这是我 ctrl-c 时的错误信息  File "<stdin>", line 2, in followUser  File "/home/user1/.local/lib/python2.7/site-packages/tweepy/binder.py", line 250, in _call    return method.execute()  File "/home/user1/.local/lib/python2.7/site-packages/tweepy/binder.py", line 190, in execute    proxies=self.api.proxy)  File "/home/user1/.local/lib/python2.7/site-packages/requests/sessions.py", line 533, in request    resp = self.send(prep, **send_kwargs)  File "/home/user1/.local/lib/python2.7/site-packages/requests/sessions.py", line 646, in send    r = adapter.send(request, **kwargs)  File "/home/user1/.local/lib/python2.7/site-packages/requests/adapters.py", line 449, in send    timeout=timeout  File "/home/user1/.local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen    chunked=chunked)  File "/home/user1/.local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request    self._validate_conn(conn)  File "/home/user1/.local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn    conn.connect()  File "/home/user1/.local/lib/python2.7/site-packages/urllib3/connection.py", line 344, in connect    ssl_context=context)  File "/home/user1/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket    return context.wrap_socket(sock, server_hostname=server_hostname)  File "/usr/lib/python2.7/ssl.py", line 369, in wrap_socket    _context=self)  File "/usr/lib/python2.7/ssl.py", line 617, in __init__    self.do_handshake()  File "/usr/lib/python2.7/ssl.py", line 846, in do_handshake    self._sslobj.do_handshake()
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 170 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信