fork download
  1.  
Success #stdin #stdout 0.02s 25740KB
stdin
import string
import requests
import itertools

def generate_links(base_link):
    """
    Generates all possible combinations by replacing 'x' with alphanumeric characters.
    """
    chars = string.ascii_letters + string.digits
    x_count = base_link.count('x')
    
    # Generate combinations for 'x' positions
    for replacements in itertools.product(chars, repeat=x_count):
        new_link = base_link
        for char in replacements:
            new_link = new_link.replace('x', char, 1)
        yield new_link

def is_valid_link(link):
    """
    Checks if the given link is valid by sending a request.
    """
    try:
        response = requests.head(link, allow_redirects=True, timeout=5)
        return response.status_code == 200
    except requests.RequestException:
        return False

def find_valid_link(base_link):
    """
    Iterates through possible links and finds a valid one.
    """
    for link in generate_links(base_link):
        if is_valid_link(link):
            return link
    return None

if __name__ == "__main__":
    # Input link with 'x' as placeholders
    base_link = input("Enter the base link with 'x' as placeholders (e.g., https://m...content-available-to-author-only...a.nz/folder/ZnsxSxxY): ").strip()
    
    print("Searching for a valid link...")
    valid_link = find_valid_link(base_link)
    
    if valid_link:
        print(f"Valid link found: {valid_link}")
    else:
        print("No valid link found.")
stdout
Standard output is empty