Home  >  Article  >  Backend Development  >  为python设置socket代理的方法

为python设置socket代理的方法

WBOY
WBOYOriginal
2016-06-06 11:20:492223browse

首先,你得下载SocksiPy这个.解压出来之后里面会有一个socks.py文件.然后你可以把这个文件复制到python安装目录里面的Lib\site-packages中.或者把这个文件复制到程序所在的目录中.
然后就可以再程序中使用socket代理来编写程序了.

下面是示例代码

import socks import socket 
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"127.0.0.1",8088) 
socket.socket =socks.socksocket import urllib2 
urllib2.urlopen('http://www.baidu.com').read()

原文:为python设置socket代理

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn