Hi,
I am working on creating a HTTP download client in Python and need little assistance.
I am getting url from command line argument (./clientprogram
www.google.com/images/test.png) and the split that url into host, path, and filename. I am only downloading and displaying images on screen tho.
Here is my lil code:
import string
import socket
import sys
import os
from subprocess import call
from urllib.parse import urlparse
# ******************************************
#
# (1) Test input arguments to program - correct number provided?
# Exit if the required URL is not provided.
# (2) Split URL into "host", "path", and "filename" variables.
# http://www.google.com/images/srpr/logo3w.png
# * host=www.google.com
# * path=/images/
# * file=test.png
# host=????
# path=????
# filename=????
# port=????
print("Preparing to download object from http://" + host + path + filename)
print()
How to do split url. Its easy to do it if url is hardcodes, but not sure it we don't know what URL will be provided by user.
Thanks
Damon