hello all im trying to code a tool to check the status for all websites in server IP : code :
its print the table header multi times i need to print it just one time how i can do that ??
# encoding=utf8 import sys reload(sys) sys.setdefaultencoding('utf8') import requests as qan import time from beautifultable import BeautifulTable import warnings warnings.filterwarnings('ignore', message='Unverified HTTPS request') table = BeautifulTable() def readfile(): with open('/root/domain.txt') as fp: for line in fp: http = "http://" + line.rstrip() u = qan.get(http ,verify= False) u = (str(u.status_code)) table.column_headers =["Website", "Status", "Time"] table.column_alignments['Website'] = BeautifulTable.ALIGN_LEFT table.set_style(BeautifulTable.STYLE_MARKDOWN) table.append_row([http, u, str(time.clock()) ]) print(table) #print(http + " \t\t\t== > Status : " + u + " \t took : " + str(time.clock()) ) readfile()when i runt it i got this result :
its print the table header multi times i need to print it just one time how i can do that ??