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

8 Replies, 1270 Views

If you're into web scraping, you should check out [Scrapy](https://scrapy.org/). It has built-in proxy support and handles a lot of the heavy lifting for you.

For python 环境使用代理, you can configure proxies in the settings:

```python
# settings.py
PROXY = 'http://your-proxy-ip:port'

# In your spider:
yield scrapy.Request(url, meta={'proxy': PROXY})
```

Way cleaner than doing it manually every time.

Messages In This Thread



Users browsing this thread: 1 Guest(s)