Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy_session() not copy proxies #2257

Open
Zerosik opened this issue May 12, 2024 · 2 comments
Open

copy_session() not copy proxies #2257

Zerosik opened this issue May 12, 2024 · 2 comments
Labels
question Question stale Issue is inactive for a long time

Comments

@Zerosik
Copy link

Zerosik commented May 12, 2024

If you look at copy_session() in instalodercontext.py, it copies the cookies and headers, but does not copy the existing proxy along with them.
When you do something that copies the session
(in my case instaloader.Profile.from_username() )
the request will be sent through my IP

To fix this, I added the following line of code to copy_session() to fix it

new.proxies = session.proxies

So my question is, is there a reason why 'copy_session()' doesn't copy the proxy?
Or am I missing something in the instructions?

my code :

L = instaloader.Instaloader()
L.context._session.proxies = {
            'http': f'http://proxyip:port',
            'https': f'http://proxyip:port',
        }
try:
    profile = instaloader.Profile.from_username(L.context, 'ash.island')
except instaloader.exceptions.ConnectionException as e :
    print(e)
posts = profile.get_posts()

for idx, post in enumerate(posts):
    L.download_post(post, profile.full_name)
    if idx >= 500:
        break
    time.sleep(random.randint(1,7))
@Zerosik Zerosik added the question Question label May 12, 2024
@Yizhe2020
Copy link

I am using the scrapingbee proxy. It seems this method is not working for me. I got an SSL verification error. If I set the new.verify = False, it returns HTTP error code 500. I am new to this. Do you have any recommendations on how to resolve the issue?

Copy link

github-actions bot commented Jun 7, 2024

There has been no activity on this question for an extended period of time. This issue will be closed after further 14 days of inactivity.

@github-actions github-actions bot added the stale Issue is inactive for a long time label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question stale Issue is inactive for a long time
Projects
None yet
Development

No branches or pull requests

2 participants