results = []
results.append(f"{site}: {port} порт активен")
with open('res.txt', 'a', encoding='UTF-8') as f:
f.write("\n".join(results))
http://example.org/login?next=profile#asdfg
http://example.org/login?next=profile%23asdfg
http://example.org/login?next=profile%23asdfg#asdfg