subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.38k stars 686 forks source link

[BUG] ProxyError HTTPSConnectionPool when using proxy #830

Closed StyleBlink closed 2 years ago

StyleBlink commented 2 years ago

I am trying to run instagrapi using proxies. I am running this

import requests
resp = requests.get('https://www.instagram.com/', proxies={'http': "http://173.230.136.148:62639"}, timeout=4)
print(resp.status_code)

and get 200 as response.

from instagrapi import Client
import os
IG_USERNAME = "**"
IG_PASSWORD = "**"
IG_CREDENTIAL_PATH = './ig_settings.json'
PROXYSTR = "http://173.230.136.148:62639"

cl = Client()
cl.set_proxy(PROXYSTR) 
if os.path.exists(IG_CREDENTIAL_PATH):
    cl.load_settings(IG_CREDENTIAL_PATH)
    cl.login(IG_USERNAME, IG_PASSWORD)
else:
    cl.dump_settings(IG_CREDENTIAL_PATH)
    cl.login(IG_USERNAME, IG_PASSWORD)

However this, gives me ClientConnectionError: ProxyError HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/accounts/contact_point_prefill/ (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000204B5703CD0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond')))

Any idea what's going on there? How could I make it work with proxy?

adw0rd commented 2 years ago

Use a different proxy provider