Tích hợp proxy với 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://

Cài đặt trong 5 bước

  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.

Câu hỏi về proxy cho Python requests

Mọi điều bạn cần để định tuyến Python requests qua Murphy, từ xác thực đến xoay vòng IP.

Nhận thông tin đăng nhập cho Python requests

Chọn mạng lưới hợp với mục tiêu của bạn. Proxy ISP cho phiên nhanh và ổn định, proxy dân cư cho nguồn IP đa dạng trước các hệ thống chống bot khắt khe.