Python FTP 应用程序中的代理 [英] Proxies in Python FTP application

查看:32
本文介绍了Python FTP 应用程序中的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Python ftplib 开发 FTP 客户端.我如何为它添加代理支持(我见过的大多数 FTP 应用程序似乎都有它)?我特别考虑 SOCKS 代理,但也考虑其他类型... FTP、HTTP(甚至可以将 HTTP 代理与 FTP 程序一起使用?)

I'm developing an FTP client in Python ftplib. How do I add proxies support to it (most FTP apps I have seen seem to have it)? I'm especially thinking about SOCKS proxies, but also other types... FTP, HTTP (is it even possible to use HTTP proxies with FTP program?)

知道怎么做吗?

推荐答案

根据 这个 来源.

依赖于代理,但常用的方法是ftp到代理,然后使用目标服务器的用户名和密码.

Depends on the proxy, but a common method is to ftp to the proxy, then use the username and password for the destination server.

例如对于 ftp.example.com:

E.g. for ftp.example.com:

Server address: proxyserver (or open proxyserver from with ftp)
User:           anonymous@ftp.example.com
Password:       password

在 Python 代码中:

In Python code:

from ftplib import FTP
site = FTP('my_proxy')
site.set_debuglevel(1)
msg = site.login('anonymous@ftp.example.com', 'password')
site.cwd('/pub')

这篇关于Python FTP 应用程序中的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆