wget not working in python
Question: I am using the os module to issue a wget request through python. It looks
something like this:

    
    
    os.system("wget 'http://superawesomeurl.com'")
    

If I issue the wget request straight from terminal, it works, but I have two
problems:

  1. When I build this in sublime, it give me the error: `sh: wget: command not found`
  2. When I enter this into a python shell command line it sends the request but comes back bad: `400 bad request`

I noticed that other people don't use the quotes around the url, but in
terminal this is the only way it works. I am using python 2.7.8 and running
Yosemite.


Answer: Your code should work if wget is on your PYTHONPATH.

## But seriously, do not use wget in Python!

Better use a Python-native function like urlopen:
<https://docs.python.org/2/library/urllib2.html#urllib2.urlopen> It's as
simple as this:

    
    
    from urllib2 import urlopen
    response = urlopen("http://stackoverflow.com").read()
    

Now `response` contains the whole contents of the html page. You can also use
`readlines()` if you wanted to iterate over it line by line. To save the html
file to disk use:

    
    
    download = open("index.html", "w")
    download.write(response.read())
    download.close()
    

