-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I'm using Python and Tweepy to fetch the Twitter followers from an account using a cursor. But I'm facing this below issue frequently, Could some one help me on how to handle this issue and Why this issue occurs.
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)
i=i+1
if i%100 == 0:
time.sleep(600)
print("sleeping")
except Exception as e:
print(e)
f.close()