0

can anyone help me about this? I just wanna set up a proxy with cmd or python. I have tried these but it doesn't work.

First try(on cmd):

netsh winhttp set proxy proxy-ip:proxy-port

Output:

C:\Windows\system32>netsh winhttp show proxy

Current WinHTTP proxy settings:
    Proxy Server(s) :  proxy-ip:proxy-port
    Bypass List     :  (none)

I checked my ip on web site. Nothing changed.

Second try:

import os
import requests

os.system('netsh winhttp set proxy proxy-ip:proxy-port')

r = requests.get("https://ipinfo.io/")

print(r.text)

Stil nothing changed. What i need to do?

Eren
  • 11
  • 4
  • Are you trying to change your OS proxy or do you want to send request using with proxyied python? because these have different solutions. – Sezer BOZKIR Dec 01 '22 at 12:31
  • @SezerBOZKIR Hayır proxy ile request göndermek istemiyorum. OS'a proxy kurmak istiyorum. Tıpkı manuel, el ile giriyoruz ya ağ ayarlarından onun gibi. – Eren Dec 01 '22 at 13:19

1 Answers1

0

When you need something major changes on OS, you should provide admin permissions, here is the solution;

pip install elevate

And you can use this code;

import os
from elevate import elevate

elevate(show_console=False)

command = 'netsh winhttp set proxy proxy_ip:proxy_port bypass-list="localhost"'
os.system(command)

You can look at the details of elevate package.

Sezer BOZKIR
  • 534
  • 2
  • 13
  • I already tried, nothing changed. Could it be that Chrome is ignoring the windows proxy settings? If so why is it accepting when I manually change the proxy setting. – Eren Dec 02 '22 at 10:14
  • If you are trying to change Selenium Chrome, you can look at here; https://stackoverflow.com/questions/11450158/how-do-i-set-proxy-for-chrome-in-python-webdriver If you want to change desktop application, you should start with like this command; google-chrome --proxy-server="socks5://127.0.0.1:1080" or you have to change the chrome default settings file; https://superuser.com/questions/149032/where-is-the-chrome-settings-file – Sezer BOZKIR Dec 02 '22 at 13:02
  • Above code is not selenium, dude. As you can see. Also I know using proxy with selenium it's super easy but i cant change my all test bot to selenium. I just wanna set proxy to Window's all run. Everyone saying this code 'netsh winhttp set proxy proxy_ip:proxy_port bypass-list="localhost"' but it doesnt work. – Eren Dec 02 '22 at 13:37
  • I succeed. I don't need help anymore. Your answer is right for someone but not for me. Should I accept it answer? Maybe someone see this answer and can find solution for itself. – Eren Dec 02 '22 at 14:28
  • Yes it will be usefull, also please add your solution to your question, we should support the future :) – Sezer BOZKIR Dec 03 '22 at 01:08