以编程方式通过Python代理发出HTTP请求

时间:2022-01-27 20:24:29

How do I use Python to make an HTTP request through a proxy?

如何使用Python通过代理发出HTTP请求?

What do I need to do to the following code?

我需要对以下代码做什么?

urllib.urlopen('http://www.google.com')

2 个解决方案

#1


The urlopen function supports proxies. Try something like this:

urlopen函数支持代理。尝试这样的事情:

urllib.urlopen(your_url, proxies = {"http" : "http://192.168.0.1:80"})

#2


You could look at PycURL. I use cURL a lot in PHP and i love it. Though there is probably a neat way to do this currently in Python.

你可以看看PycURL。我在PHP中使用cURL很多,我喜欢它。虽然目前在Python中可能有一种简洁的方法可以做到这一点。

#1


The urlopen function supports proxies. Try something like this:

urlopen函数支持代理。尝试这样的事情:

urllib.urlopen(your_url, proxies = {"http" : "http://192.168.0.1:80"})

#2


You could look at PycURL. I use cURL a lot in PHP and i love it. Though there is probably a neat way to do this currently in Python.

你可以看看PycURL。我在PHP中使用cURL很多,我喜欢它。虽然目前在Python中可能有一种简洁的方法可以做到这一点。