Reputation: 5972
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
Upvotes: 1
Views: 595
Reputation: 78690
strip
the newline character (and useless whitespace) from url
:
print '%-15s %15s' % (url.strip(), status)
Upvotes: 2