My program tries to look for web page links And when the page is valid the application writes [+] Found [+] and if the link is not valid it writes [+] Error [+] but each link does not have the same length. Here is an example of how the app looks when I run it foobar.com/test [+] Found [+]
foobar.com/test21 [+] Error [+]
foobar.com/test333 [+] Error [+]
As you can see the position of the message moves because the link is longer. I want the message from Found
o Error
to appear in the same vertical row like this:
foobar.com/test [+] Found [+]
foobar.com/test21 [+] Error [+]
foobar.com/test333 [+] Error [+]
But not so close to the link because there may be an error that would be if a link is longer than the length between the link and the message Error
or Found
Here is my code
for i in array:
try:
adminpanel = urllib2.urlopen(website+i)
checkurl = adminpanel.code
if checkurl == 200:
print Fore.GREEN+ website+i," "" " +"[+] Found [+] "
continue
except urllib2.URLError, checkurl:
if checkurl == 404:
print website+i," "" Not Found :/"
else:
print Fore.RED+ website+i," "" " +"[+] Error [+] " + Style.RESET_ALL
If you know all the links in advance, which it seems you do, you can do the following:
The above code should leave you two spaces at the end of the longest link and more spaces at the end of the other links.
In the part of your code I add the desired number of spaces in each
print
using the maximum length of a link and the length of the link in use in order to be able to enter the necessary number of spaces.[I haven't tested the code since I don't have a python2.7 installed on this PC]