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]).
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
- 1Install the client with pip install requests (add requests[socks] for SOCKS5).
- 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.
- 3Build the proxy URL as http://user:pass@host:port and map both http and https to it in the proxies dict.
- 4Set a timeout so a stalled connection fails fast instead of hanging your run.
- 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.
Put the credentials in the proxy URL itself: http://USERNAME:PASSWORD@gw-eu.murphyproxies.com:8888 for residential, or http://USER:PASS@IP:PORT built from one of your ISP lines. requests reads the user and password from the URL, so you do not need a separate auth header or a ProxyManager.
Yes. Install the SOCKS dependency with pip install requests[socks], then change the scheme in the proxy URL to socks5 (or socks5h to resolve DNS through the proxy). Everything else in the code stays the same.
On residential proxies, the dashboard builds it into the credentials: pick rotating for a new IP on every request, or sticky to keep the same IP for up to 48 hours, along with the country you target, then copy the line it generates. The requests code does not change. ISP proxies are static, so each one keeps its IP and you spread load by cycling through your list of dedicated IPs.
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.