I've been developing a Python tool to generate a bit.ly wordlist. Here are the particularities of bit.ly links:
- Contain 7 entities
- Begin with a number (generally 3 or 2)
- End with a letter
- Can't have the same entity side by side
I already did the first 3 conditions, but I can't find a way to do the last.
from itertools import product
def firstN(chars, length):
for firstNumber in product(chars, repeat=length):
yield ''.join(firstNumber)
def combiwords(chars, length):
for letters in product(chars, repeat=length):
yield ''.join(letters)
def lastL(chars, length):
for lastLetter in product(chars, repeat=length):
yield ''.join(lastLetter)
def main():
firstNumber = "32"
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
lastLetter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
for wordlen1 in range(1, 2):
for first in firstN(firstNumber, wordlen1):
for wordlen2 in range(6, 7):
for combo in combiwords(letters, wordlen2):
for wordlen3 in range(1, 2):
for word in lastL(lastLetter, wordlen3):
print('https://bit.ly/' + first + combo + word)
if __name__=="__main__":
main()
Solution
I wrote a couple of functions which can solve your problem:
Results
With the following code executed
I've had the following result:
If you have any questions, just ask in the comments. I hope it helped!