Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect python application to internet through proxy IP?

At my workplace we access internet through a proxy server IP entered in Preferences > Network > Connection > Manual Proxy configuration. where the Proxy IP is entered, I want to learn how to do that setup in python so for my internet based application .

like image 666
Ciasto piekarz Avatar asked Aug 22 '26 05:08

Ciasto piekarz


1 Answers

You can set http_proxy environment variable or you can set this information accordly with lib used. As example, requests libs:

import requests

proxies = {
  "http": "http://10.10.1.10:3128",
  "https": "http://10.10.1.10:1080",
}

requests.get("http://example.org", proxies=proxies)

UPDATE

A tool that can help in corporate environments is cntlm http://cntlm.sourceforge.net/ , an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy.

Once configured, you only have to point to your proxy in http://localhost:3128.

like image 78
andmart Avatar answered Aug 24 '26 21:08

andmart