CA
genetic-orange
Using apify proxy
My actor was created using python so I would like to know if how I added the proxy code to my actor is correct. If it is not, then how should I be adding it. Thanks in advance.
16 Replies
firstly you really should not share your proxy password publicly so please reset it on https://console.apify.com/proxy
I am not python expert, so I can just say that this
f"http://auto:{password}@proxy.apify.com:8000"
seens correctgenetic-orangeOP•3y ago
sorry about that, forgot to take it out. i have removed it from the post and reset it. also, thank you for your input. it feels correct to me as well but i just want to make sure.
rare-sapphire•3y ago
This looks quite correct
Sharing my notes below:
general approach is to find a way to set proxy at global level or as a wrapper. For Python its possible to define proxy at OS-level as follows:
import os
os.environ['HTTP_PROXY'] = os.environ['http_proxy'] = 'http://http-connect-proxy:3128/'
os.environ['HTTPS_PROXY'] = os.environ['https_proxy'] = 'http://http-connect-proxy:3128/'
os.environ['NO_PROXY'] = os.environ['no_proxy'] = '127.0.0.1,localhost,.local'
And it will override even Apify client obviously, so before pushing data to Apify cloud proxy needs to be reset.
If we need more than that for Python there is https://github.com/darkk/redsocks or https://github.com/Anorov/PySocks as well.
genetic-orangeOP•3y ago
thank you all for the input!
national-gold•3y ago
Hi, I am writing an actor in python, the problem is how can I make a user to must use apify proxy rotation via input, I am unable to find that in docs. I will highly appreciate any help.
rare-sapphire•3y ago
Are you just trying to make it a required input field, or trying to actually implement it?
national-gold•3y ago
Yes I want to make it required input field such that the user uses his own proxy rotation using apify platform.
rare-sapphire•3y ago
Here's a sample
INPUT_SCHEMA.json
:
national-gold•3y ago
Oh, Thanks alot, how can I make it to use residential proxies only?
@Jawad Ahmad Khan just advanced to level 1! Thanks for your contributions! 🎉
rare-sapphire•3y ago
They choose which proxies they'd like to use
Some users don't have access to residentials
rare-sapphire•3y ago
I'd also recommend referring to this code snippet: https://developers.apify.com/academy/apify-platform/deploying-your-code/inputs-outputs#accepting-input-without-the-apify-sdk
Apify
Inputs & outputs · Apify Developers
Learn to accept input into your actor, do something with it, then return output. Actors can be written in any language, so this concept is language agnostic.
rare-sapphire•3y ago
You can copy the
get_input()
functionnational-gold•3y ago
Thank you very much, I really appreciate that 🙂
However this is what I am getting when using proxy.
<Response [403]> The "Proxy external access" feature is not enabled for your account. Please upgrade your plan or contact [email protected]
However the actor I am writing needs to use proxy if a user wants to use it, how can I make sure that before any user wants to use my actor has to use proxy, for example if a user comes for testing out the actor and without using the proxy this is what he will get, which is a bad experience.
I can not use my own proxy in the actor, as first the pricing issue second I will be exposing my proxy user and password.
Can anyone please recommend anything regarding that. Thanks
My free plan shows I have access to 20 datacenter proxies, still when I try to use them during actor development phase I get:
<Response [403]> The "Proxy external access" feature is not enabled for your account. Please upgrade your plan or contact [email protected]
rare-sapphire•3y ago
@Jawad Ahmad Khan Did you get this resolved?