Интеграция прокси с Python requests

The requests library reads a proxies dictionary on every call, so pointing Python at a Murphy proxy takes two lines. Put your username and password in the proxy URL and the same credentials cover HTTP and HTTPS traffic. Residential proxies go through a regional gateway such as gw-eu.murphyproxies.com on port 8888, ISP proxies through one of your dedicated IPs, both copied from your dashboard. For SOCKS5 support, install requests with the socks extra (pip install requests[socks]).

fetch.pypython
import requests

# Residential: a regional gateway (gw-eu, gw-usa, gw-asia or gw-asia2), port
# 8888 (7777 on Private 2), with the username and password your dashboard generates.
proxy = "http://USERNAME:PASSWORD@gw-eu.murphyproxies.com:8888"

# ISP: one dedicated IP from your list. The dashboard shows each one as
# ip:port:user:pass, rewrite it as user:pass@ip:port.
# proxy = "http://USER:PASS@IP:PORT"

proxies = {"http": proxy, "https": proxy}

resp = requests.get(
    "https://httpbin.org/ip",
    proxies=proxies,
    timeout=30,
)
print(resp.status_code, resp.json())

# SOCKS5 instead of HTTP (needs: pip install requests[socks]):
# keep the same URL and change the scheme to socks5h://

Настройка за 5 шагов

  1. 1Install the client with pip install requests (add requests[socks] for SOCKS5).
  2. 2Copy your credentials from the dashboard: a residential username and password for gw-eu.murphyproxies.com:8888 (or another gw- region, 7777 on Private 2), or one ISP line in ip:port:user:pass form.
  3. 3Build the proxy URL as http://user:pass@host:port and map both http and https to it in the proxies dict.
  4. 4Set a timeout so a stalled connection fails fast instead of hanging your run.
  5. 5Print resp.json() from an IP echo endpoint to confirm the request left through the proxy.

Вопросы о прокси для Python requests

Всё, что нужно, чтобы пустить Python requests через Murphy, от авторизации до ротации.

Получите доступы для Python requests

Выберите сеть под свою задачу. ISP-прокси для быстрых и стабильных сессий, резидентные, когда против жёстких антиботов нужно много разных IP.

Другие интеграции