Oct-29-2019, 11:00 AM
(This post was last modified: Oct-29-2019, 11:00 AM by newbieAuggie2019.)
Hi again!
My understanding, seeing your first post, is that your code runs properly, but it prints the header row every time it reads
If the program that you posted on your first post was running fine, and the only thing not wanted was that the header line was printed more than once, then I would suggest you try this one:
My understanding, seeing your first post, is that your code runs properly, but it prints the header row every time it reads
for line in fp
because you made the program to print the headers inside the loop for every line read in fp with this part of your code: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()) ])I think that if the image you posted corresponds to that first program, then you should try to leave out of the loop, just the part establishing the unchangeable characteristics to set the table.
If the program that you posted on your first post was running fine, and the only thing not wanted was that the header line was printed more than once, then I would suggest you try this one:
# 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: table.column_headers =["Website", "Status", "Time"] table.column_alignments['Website'] = BeautifulTable.ALIGN_LEFT table.set_style(BeautifulTable.STYLE_MARKDOWN) for line in fp: http = "http://" + line.rstrip() u = qan.get(http ,verify= False) u = (str(u.status_code)) table.append_row([http, u, str(time.clock()) ]) print(table)All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs