Nitesh Sharma
Nitesh Sharma

Reputation: 19

How to run Curl Command in Python

I want to run Following Curl Command in Python and I was trying the requests command of python but I am not getting the proper results.

curl -v ftp://ftp.abc.com/File.txt --socks5-hostname socks.abc.com:PORT --user username:password -O

Upvotes: 1

Views: 4122

Answers (1)

max wiklund
max wiklund

Reputation: 113

You can use subprocess.

import subprocess
result = subprocess.run(["curl", "-v", "ftp://ftp.abc.com/File.txt --socks5-hostname socks.abc.com:PORT --user username:password -O"], capture_output=True)
print(result.stdout)

I'm not into web development but this looks like something the requests module should be able to handle.

r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
r.status_code

https://requests.readthedocs.io/en/master/

Upvotes: 1

Related Questions