Fail to pass user input to wget in python -


i pass user input wget download content of web page.

  user_input = raw_input "type url here.. "    os.system("wget -o /directory/, user_input") 

the code above did not work because wget not take user input, wget "user_input" instead. there way round problem?

thank you

you not passing variable, use subprocess module:

from subprocess import check_call  user_input = raw_input("type url here.. ")  check_call(["wget", "-o", "directory/foo.html", user_input]) 

in code need pass variable:

 os.system("wget -o /directory  {}".format(user_input)) 

if command returns non-zero exit status calledprocesserror using check_call.

the easiest way save file let user pick name , add extension. parse url passed there many possible variations consistently:

user_input = raw_input("type url here.. ") save_as = raw_input("enter name save file as...")  check_call(["wget", "-o", "{}.html".format(save_as), user_input]) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -