python 中的curl --interface 等价物

标签 python linux shell centos

以下 shell 命令的 python 等效项是什么: curl --interface 10.91.56.2 http://10.91.55.3/file0.txt
????

我使用的是CentOS6.5-Linux,我想从虚拟IP地址(如eth0:0、eth0:1、eth0:2等)与eth0同时发送http请求。我实际上正在尝试使用 python 制作一款流量生成器工具。我已成功发送多个并发 http 请求,现在我的下一步是从多个 IP 地址发送此类请求。我使用以下 cURL 命令从 eth0:1“curl--interface 10.91.56.2 http:/10.91.55.3/file0.txt”发送请求,并且成功从虚拟 eth0:1 生成流量。谁能指导我如何使用 python 来做到这一点? 10.91.56.2 是我的虚拟 eth0:1 IP 接口(interface),10.91.55.3 是我的服务器地址... –

最佳答案

Python Urllib2 为发出任何 HTTP 请求提供了完美的平台。在您的情况下,您可以使用 urlopen() 函数...

有关此库的更多信息可以在以下链接中找到:

how-to-use-urllib2-in-python

关于python 中的curl --interface 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27103386/

相关文章:

python - `python manage.py shell`启动后执行脚本

python - django-schedule project_sample 错误

python - Python中的百分号是什么意思

c - XLIB 如何使窗口全屏显示?

bash - 为什么 9 之后的 bash 命令行参数需要大括号?

linux - 删除格式的所有两行的命令

python - 通过 WholeBodyMotion 控制机器人 ARM

python2.7名称 '__path__'未定义

linux - 在 Jenkins 中使用 ant sshexec 运行脚本时如何更改工作目录?

linux - 我可以使 TCP Keep-Alive 对称吗?