I'm trying to fetch the Twitter followers data using python and Tweepy. But I'm facing an exception frequently and don't know why it occurs and how to handle it. Could some one help me to solve this. Also How do I stop the loop when the cursor fetches the last follower in the account.

Error: TTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/followers/list.json?cursor=1516792635609098963&id=%40Careers (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',)))

Code

def process_follower(follower,i):
Mycode

consumer_key = '*********'
consumer_secret = ''********''
access_token = ''********************''
access_token_secret = ''************''

import sys
import os
import tweepy
import time

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

get_user_to_query = 'Accountname'

f = open('Account_followers_Location04012017.json', 'w', encoding='utf-8', errors="surrogateescape")

try:
for follower in tweepy.Cursor(api.followers, id = get_user_to_query).items():
#print(follower.name)
process_follower(follower, i)
except Exception as e:

print(e) 
f.close()
0

There are 0 answers