如何在 Python 环境使用代理?有没有简单的方法?

8 Replies, 1238 Views

For async scraping, `aiohttp` is solid, but if you want something simpler, try `httpx`. It’s async and sync, so you can switch between them easily.

Here’s how you can use proxies with `httpx`:

```python
import httpx

proxies = "http://your-proxy-ip:port"
with httpx.Client(proxies=proxies) as client:
response = client.get("http://example.com")
```

Also, for free proxies, check out [ProxyList](https://www.proxylist.net/). Makes python 环境使用代理 a breeze.

Messages In This Thread



Users browsing this thread: 1 Guest(s)