前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python通过代理服务器访问ftp服务

python通过代理服务器访问ftp服务

原创
作者头像
代码伴一生
修改2021-11-03 13:14:26
1.8K0
修改2021-11-03 13:14:26
举报
文章被收录于专栏:代码伴一生代码伴一生

import urllib2

Install proxy support for urllib2

proxy_info = { 'host' : 'proxy.myisp.com', 'port' : 3128, } proxy_support = urllib2.ProxyHandler({"ftp" : % proxy_info}) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener)

List the content of a directory (it returns an HTML page built by the proxy)

(You will have to parse the HTML to extract the list of files and directories.)

print urllib2.urlopen("ftp:").read()

Download a file:

data = urllib2.urlopen("ftp").read() open("myfile.zip","w+b").write(data)</pre>

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Install proxy support for urllib2
  • List the content of a directory (it returns an HTML page built by the proxy)
  • (You will have to parse the HTML to extract the list of files and directories.)
  • Download a file:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档