Skip to content

How to set proxy in requests. #59

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

Closed
mdrijwan123 opened this issue Apr 6, 2020 · 3 comments
Closed

How to set proxy in requests. #59

mdrijwan123 opened this issue Apr 6, 2020 · 3 comments

Comments

@mdrijwan123
Copy link

mdrijwan123 commented Apr 6, 2020

I want to fetch some data with requests and it's working fine. But in some cases I want to use the proxy.
in Python requests option is:
proxy = "{"http":"http://URL"}"
r = requests.get(URL,proxy = proxy) # and it works
But in requests scala, I am using the same thing. and getting errors:
found: String
[error] required: (String, Int)
[error] val content = requests.get(URL, headers = Map("Content-Type" -> "application/json"), proxy = proxy)
I don't know what is the required parameter (String, Int) that I need to pass.
If anybody found the same issue and got solved please help.

@mdrijwan123
Copy link
Author

Hey, Due to less documentation following few hyperparameters is still not known.
Under requests following are the Hyper-Parameters:

url: String,auth: requests.RequestAuth,params: Iterable[(String, String)],headers: Iterable[(String, String)],data: requests.RequestBlob,readTimeout: Int,connectTimeout: Int,proxy: (String, Int),cookies: Map[String,java.net.HttpCookie],cookieValues: Map[String,String],maxRedirects: Int,verifySslCerts: Boolean,autoDecompress: Boolean,compress: requests.Compress,keepAlive: Boolean

So, if I have my Proxy 10.89.67.00 and port is 8190 then I'll use:
requests.get(URL,headers = Map("content-type"->"application/json"),proxy = ("10.89.67.00",8190))
And it's working.

@anicolaspp
Copy link

anicolaspp commented Apr 7, 2020

@mdrijwan123 what about proxy with user:password ???

@mdrijwan123
Copy link
Author

@anicolaspp hey if you just search:
proxy_http=username:password@proxy-host:port
Maybe putting 'username:password@proxy-host' as a first argument and port in other will solve.
i.e. proxy = (username:password@proxy-host,port)
I am not sure will it work or not because in my case giving host and port was enough.
Just try it and let us know if it works. If not then this feature is not being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants