Inital Commit

This commit is contained in:
2026-07-14 18:48:55 -06:00
commit e3f9845ea1
2 changed files with 111 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
.venv/
build/
dist/
*.txt
*.spec
+106
View File
@@ -0,0 +1,106 @@
import requests
import sys
import validators # type: ignore
import os
print("Rete URL Checker by koffee.zip")
exist = True
try:
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
print("Usage: Rete [arguments] [URLs]")
print("-h --help Shows this help page")
print("-f --file Lets you check URLs via a txt file.")
exit(0)
if sys.argv[1] == "-f" or sys.argv[1] == "--file":
count = 0
passed = 0
failed = 0
with open(os.path.expanduser(sys.argv[2]), "r") as fp:
for line in fp:
if not validators.url(line.strip()):
exist = False
else:
exist = True
if exist == True:
try:
response = requests.get(line.strip(), timeout=1)
except:
exist = False
try:
if response.status_code == 200 or response.status_code == 403:
print(f"Passed: {line.strip()} Status Code: {response.status_code}")
with open("passed.txt", 'a') as file:
file.write(f"\n{line.strip()}")
response.status_code = None
passed += 1
elif exist == False:
print(f"Failed: {line.strip()} server was not found, invalid url, or timed out")
with open("failed.txt", 'a') as file:
file.write(f"\n{line.strip()}")
failed += 1
else:
print(f"Failed: {line.strip()} Error Code: {response.status_code}")
with open("failed.txt", 'a') as file:
file.write(f"\n{line.strip()}")
failed += 1
except Exception as e:
if exist == False:
print(f"Failed: {line.strip()} server was not found, invalid url, or timed out")
with open("failed.txt", 'a') as file:
file.write(f"\n{line.strip()}")
failed += 1
else:
print(e)
exit
with open(sys.argv[2], 'r') as file:
line_count = sum(1 for line in file)
print("====================================")
print(f"{failed}/{line_count} URLs have failed.")
print(f"{passed}/{line_count} URLs have passed")
print("You can see all the passed URLs in passed.txt and failed URLs in failed.txt")
else: # No arg here
passed = 0
failed = 0
for i in range(len(sys.argv) - 1):
if not validators.url(sys.argv[i + 1]):
exist = False
else:
exist = True
if exist == True:
try:
response = requests.get(sys.argv[i + 1], timeout=1)
except:
exist = False
try:
if response.status_code == 200 or response.status_code == 403:
print(f"Passed: {sys.argv[i + 1]} Status Code: {response.status_code}")
response.status_code = None
passed += 1
elif exist == False:
print(f"Failed: {sys.argv[i + 1]} server was not found, invalid url, or timed out")
failed += 1
else:
print(f"Failed: {sys.argv[i + 1]} Error Code: {response.status_code}")
failed += 1
except Exception as e:
if exist == False:
print(f"Failed: {sys.argv[i + 1]} server was not found, invalid url, or timed out")
failed += 1
else:
print(e)
print("====================================")
print(f"{failed}/{i + 1} URLs have failed.")
print(f"{passed}/{i + 1} URLs have passed")
except IndexError:
print("Usage: Rete [arguments] [URLs]")
print("-h --help Shows this help page")
print("-f --file Lets you check URLs via a txt file.")