0
def wget_url(url):     
   try:
        wget = subprocess.Popen(["wget "+url],shell=True,stdout=PIPE,stderr=PIPE)
        return wget
   except:
        print("HTTP error")

a=wget_url(url)
a.stdout.readlines() #return an empty string.
a.stderr.readlines() #return the normal output that would be displayed in terminal

is this normal? Why stdout returns nothing?

Bonfel
  • 11
  • 4

1 Answers1

0

This isn't Python problem but a feature of wget:

 wget url >  stdout.txt 2> stderr.txt

Here stdout.txt is empty and stdout.txt 2> has the screen output with 200 OKetc. This is a well known fact. Diagnostic messages could interfere with piping and therefore are better routed to stderr.

Mike Müller
  • 82,630
  • 20
  • 166
  • 161