Skip to content

Instantly share code, notes, and snippets.

@lucasburlingham
Created November 21, 2020 15:35
Show Gist options
  • Save lucasburlingham/882c2ec44ea8c71847c7bb4133c1c634 to your computer and use it in GitHub Desktop.
Save lucasburlingham/882c2ec44ea8c71847c7bb4133c1c634 to your computer and use it in GitHub Desktop.
# Scans all possible combinations of the variable 'characterList' and then evaluates
# if there is a valid website associated with the domain
from itertools import chain, combinations
import requests
def createLink(iterable):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
characterList = 'abcdefghi'
tempLink = list(map(''.join, createLink(characterList)))
logFile = open("log.txt", 'a')
protocol = 'http://'
extension = '.com'
# urls include: protocol (https://, http://, ftp://, smb://, etc.) + domainname (google, golca,
# bing, etc.) + domain extension (.com, .org, .net, .uk, etc.)
link = [protocol + domain + extension for domain in tempLink]
del link[0] # deletes the first and blank object in the array
print(link)
linkLength = len(link)
for i in range(linkLength):
try:
response = requests.get(link[i])
print(link[i])
print("URL is valid and exists on the internet \n")
iteration = str(i)
logFile.write("URL " + link[i] + " is valid and responds with a 200 code \n")
logFile.write("Iteration: " + iteration + ". \n")
except requests.ConnectionError as exception:
print("URL does not exist on the Internet")
logFile.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment