Python Forum
BeautifulTable print header multi times
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BeautifulTable print header multi times
#3
thank u brother for replay and for trying to help but unfortunately does not work i test it on multi machines with py3 and py2 i dont know what is the problem :( i will send u my domain list on inbox check it and try to help me : my final code :

# encoding=utf8
import sys
#reload(sys)
#sys.setdefaultencoding('utf8')
import requests as qan
import time 
from beautifultable import BeautifulTable
import warnings
from datetime import datetime
now = datetime.now() # current date and time
from timeit import default_timer as timer


warnings.filterwarnings('ignore', message='Unverified HTTPS request')

table = BeautifulTable()

def readfile():
    
    with open('/root/domain.txt') as fp:
        
        for line in fp:
            try:
                start = timer()
                http = "http://" + line.rstrip()
                u = qan.get(http ,verify= False)
                u = (str(u.status_code))
                table.column_headers =["Website", "Status", "Time S/M "]
                table.column_alignments['Website'] = BeautifulTable.ALIGN_LEFT
                table.set_style(BeautifulTable.STYLE_MARKDOWN)
                end = timer()
                table.append_row([http, u, str(end - start) ])
   
                print(table)
                #print(http + " \t\t\t== > Status : " + u + " \t took : " + str(time.clock()) )
                continue
            except qan.exceptions.HTTPError as errh:
                continue
            except qan.exceptions.ConnectionError as errc:
                continue
            except qan.exceptions.Timeout as errt:
                continue
            except qan.exceptions.RequestException as err:
                continue



readfile()
Output:
| Website | Status | Time S/M | |---------------------|--------|-----------| | http://xxxxx.com.ni | 200 | 1.008 | | Website | Status | Time S/M | |--------------------------------|--------|-----------| | http://xxxxx.com.ni | 200 | 1.008 | | http://xxxxxxxxxxxxxxxx.com.ni | 200 | 0.82 | | Website | Status | Time S/M | |--------------------------------|--------|-----------| | http://xxxxx.com.ni | 200 | 1.008 | | http://xxxxxxxxxxxxxxxx.com.ni | 200 | 0.82 | | http://xxxxxxx.com.ni | 200 | 0.516 | | Website | Status | Time S/M | |--------------------------------|--------|-----------| | http://xxxxx.com.ni | 200 | 1.008 | | http://xxxxxxxxxxxxxxxx.com.ni | 200 | 0.82 | | http://xxxxxxx.com.ni | 200 | 0.516 | | http://xxxxxxxxx.com.ni | 200 | 0.538 |
Reply


Messages In This Thread
RE: BeautifulTable print header multi times - by evilcode1 - Oct-29-2019, 08:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to print string multiple times on new line ace19887 7 6,008 Sep-30-2020, 02:53 PM
Last Post: buran
  How to print string multiple times separated by delimiter Mekala 1 2,018 May-23-2020, 09:21 AM
Last Post: Yoriz
  Print 'X' a number of times Than999 1 2,731 Jan-18-2020, 06:41 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020