Python FTP 应用程序中的代理

编程入门 行业动态 更新时间:2024-10-11 05:30:14
本文介绍了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:

E.g. for ftp.example:

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

在 Python 代码中:

In Python code:

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

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

更多推荐

[db:关键词]

本文发布于:2023-03-28 15:04:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/733309.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   Python   FTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!