1

I wrote a simple python script like this:

#!/usr/bin/python
import sys
import urllib

if len(sys.argv) < 2:
        print 'usage: python %s <file-urls>' % (sys.argv[0])
        sys.exit(2)

print '%-15s %15s' % ('URL_PAGE', 'STATUS')

FileName = sys.argv[1]
InputFile = open(FileName)
for url in InputFile:
    out = urllib.urlopen(url)
    status = out.getcode()
    print '%-15s %15s' % (url, status)

The out put is something like this:

URL_PAGE                 STATUS
http://test.com
             200

But I want this output:

URL_PAGE                 STATUS
http://test.com           200
MLSC
  • 5,872
  • 8
  • 55
  • 89

1 Answers1

2

strip the newline character (and useless whitespace) from url:

print '%-15s %15s' % (url.strip(), status)
timgeb
  • 76,762
  • 20
  • 123
  • 145