### Basic Setup for PyLookyloo Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md Demonstrates the basic steps to set up and import the PyLookyloo client. Ensure Python 3.10+ is installed and the library is installed via pip. ```python from pylookyloo import Lookyloo # Basic client creation lookyloo = Lookyloo() ``` -------------------------------- ### Install PyLookyloo with Extras Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Install PyLookyloo with optional dependencies for documentation generation or running examples. ```bash pip install pylookyloo[docs] # sphinx for documentation pip install pylookyloo[examples] # pylacus for examples ``` -------------------------------- ### Install PyLookyloo with Optional Dependencies Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Install PyLookyloo along with optional dependencies for documentation building or examples. Use comma-separated values for multiple extras. ```bash # Documentation building pip install pylookyloo[docs] # Examples pip install pylookyloo[examples] # Both pip install pylookyloo[docs,examples] ``` -------------------------------- ### Basic Capture Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates a basic capture of a URL using the Lookyloo client. No special setup or authentication is required for this simple case. ```python from lookyloo import Lookyloo lookyloo = Lookyloo() result = lookyloo.submit('https://www.example.com') print(result) ``` -------------------------------- ### Install PyLookyloo Source: https://github.com/lookyloo/pylookyloo/blob/main/README.md Install the PyLookyloo library using pip. ```bash pip install pylookyloo ``` -------------------------------- ### Search/Redirects Return Value Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Example of the JSON output format for --redirects, --search-url, and --search-hostname arguments, listing capture UUIDs and total count. ```json { "captures": ["uuid1", "uuid2", ...], "total": 42 } ``` -------------------------------- ### Query Return Value Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Example of the output when using the --query argument, which prints the permanent URL or UUID of the captured resource. ```text https://lookyloo.circl.lu/tree/a1b2c3d4-e5f6-7890-abcd-ef1234567890 ``` -------------------------------- ### Install PyLookyloo for Development Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Install PyLookyloo in editable mode with development and documentation dependencies, including type checking tools. ```bash pip install -e ".[docs,examples]" pip install mypy pytest types-requests ``` -------------------------------- ### Monitor URL for Changes Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md This example outlines how to set up URL monitoring. This feature allows you to track changes to a URL over time. ```python # Specific method for URL monitoring would be used here. # Refer to documentation for 'URL monitoring' examples. ``` -------------------------------- ### CLI: Basic Query Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates a basic usage of the lookyloo CLI to query for a specific URL. This is the simplest way to interact with the tool from the command line. ```bash lookyloo --query https://www.example.com ``` -------------------------------- ### Example: Get Captures from Last Hour Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Demonstrates how to use `get_recent_captures` to retrieve capture UUIDs from the past hour. ```python from datetime import datetime, timedelta # Get captures from last hour one_hour_ago = datetime.now() - timedelta(hours=1) recent = lookyloo.get_recent_captures(timestamp=one_hour_ago) ``` -------------------------------- ### Simple Capture Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Demonstrates a basic capture of a URL using the Lookyloo library. This is useful for quick captures where default settings are sufficient. ```python from pylookyloo import Lookyloo lookyloo = Lookyloo() uuid = lookyloo.submit(url='https://example.com', quiet=True) print(f"Capture ready at: {lookyloo.root_url}tree/{uuid}") ``` -------------------------------- ### Example Typed Function for Capture and Analysis Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/types.md An example of a Python function using type hints for URL input and returning a string UUID. It demonstrates initializing `Lookyloo`, submitting a capture, and retrieving status. ```python from pylookyloo import Lookyloo def capture_and_analyze(url: str) -> str: lookyloo: Lookyloo = Lookyloo() uuid: str = lookyloo.submit(url=url, quiet=True) status: dict = lookyloo.get_status(uuid) return uuid ``` -------------------------------- ### MISP Integration Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates how to export captured data to MISP (Malware Information Sharing Platform). This requires a configured MISP instance and API key. ```python from lookyloo import Lookyloo lookyloo = Lookyloo(misp_url='https://misp.example.com', misp_api_key='my_misp_key') result = lookyloo.submit('https://malicious.example.com') capture_id = result['capture_id'] misp_export = lookyloo.export_to_misp(capture_id) print(f'Exported to MISP: {misp_export}') ``` -------------------------------- ### URL normalization examples for Lookyloo constructor Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Demonstrates how the `root_url` parameter is normalized by PyLookyloo, including scheme and trailing slash auto-addition. ```python Lookyloo('example.com') # → 'http://example.com/' Lookyloo('https://example.com') # → 'https://example.com/' Lookyloo('https://example.com/api') # → 'https://example.com/api/' ``` -------------------------------- ### Wait for Capture Completion Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md This example demonstrates how to wait for a capture process to complete. This is often necessary before attempting to retrieve capture artifacts. ```python # Assuming 'submission_id' is obtained from lookyloo.submit() # lookyloo.wait_for_completion(submission_id) ``` -------------------------------- ### Deprecated CaptureSettings Usage Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/types.md This example demonstrates how to use the deprecated `CaptureSettings` TypedDict with PyLookyloo. It is not recommended for new code. ```python from pylookyloo import CaptureSettings, Lookyloo settings: CaptureSettings = { 'url': 'https://example.com', 'browser': 'chromium', 'listing': True } lookyloo = Lookyloo() uuid = lookyloo.submit(capture_settings=settings, quiet=True) ``` -------------------------------- ### Try/Catch Example for AuthError Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates how to specifically catch an `AuthError` when authentication fails. This allows for targeted error handling for login or API key issues. ```python from lookyloo import Lookyloo, AuthError try: lookyloo = Lookyloo(api_key='wrong_api_key') lookyloo.submit('https://example.com') except AuthError as e: print(f'Authentication failed: {e}') ``` -------------------------------- ### Verify PyLookyloo Installation Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Confirm that PyLookyloo has been installed correctly by importing the Lookyloo class and printing it. This checks if the package is accessible in your Python environment. ```python from pylookyloo import Lookyloo print(Lookyloo) ``` -------------------------------- ### User-Agent String Format Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Example of how the PyLookyloo version is incorporated into the default User-Agent string. ```python f'PyLookyloo / {version("pylookyloo")}' ``` -------------------------------- ### Usage of Deprecated CompareSettings Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/types.md Example demonstrating how to use the deprecated CompareSettings TypedDict with the compare_captures method. ```python settings: CompareSettings = { 'ressources_ignore_domains': ['analytics.example.com', 'tracking.example.com'], 'ressources_ignore_regexes': [r'.*utm_.*', r'.*fbclid=.*'] } diff = lookyloo.compare_captures(uuid1, uuid2, compare_settings=settings) ``` -------------------------------- ### Get All Hostnames from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves a dictionary of all hostnames that were contacted during a capture. ```python def get_hostnames(self, capture_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Parse JSON Output with jq Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Examples of using the `jq` command-line JSON processor to query and format JSON output from Lookyloo CLI commands. ```bash # Get first 3 capture UUIDs lookyloo --search-url "https://tracking.example.com" | jq '.captures[0:3]' ``` ```bash # Extract total count lookyloo --search-url "https://tracking.example.com" | jq '.total' ``` ```bash # Pretty print lookyloo --redirects {uuid} | jq . ``` -------------------------------- ### Secure Capture Function with Type Hints Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Example function demonstrating type-hinted usage of the Lookyloo client for secure capture with API key authentication. ```python from pylookyloo import Lookyloo, AuthError, PyLookylooError from pathlib import Path def secure_capture(url: str, api_key: str) -> str: """Capture with authentication.""" lookyloo: Lookyloo = Lookyloo() try: lookyloo.init_apikey(apikey=api_key) except AuthError as e: raise ValueError(f"Auth failed: {e}") uuid: str = lookyloo.submit(url=url, quiet=True) return uuid ``` -------------------------------- ### List Remote Lacus Instances Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Fetches a list of configured remote Lacus instances connected to the Lookyloo setup. ```python def get_remote_lacuses(self) -> list[dict[str, Any]] ``` -------------------------------- ### CLI: Listing Captures with Redirects Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates using the --listing and --redirects flags in the lookyloo CLI to get a list of captures and follow redirects. This provides a more detailed view of capture history. ```bash lookyloo --listing --redirects ``` -------------------------------- ### Get HTML as Markdown Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve the rendered HTML content converted into Markdown format. The result is provided as a StringIO object. ```python lookyloo.get_html_as_markdown(capture_uuid) ``` -------------------------------- ### Modern CaptureSettings Usage with Pydantic Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/types.md This example shows the recommended modern approach using Pydantic models from `lookyloo-models` for capture settings with PyLookyloo. Pydantic models provide built-in validation. ```python from lookyloo_models import LookylooCaptureSettings from pylookyloo import Lookyloo settings_dict = { 'url': 'https://example.com', 'browser': 'chromium', 'listing': True } # Pydantic model provides validation settings = LookylooCaptureSettings.model_validate(settings_dict) lookyloo = Lookyloo() uuid = lookyloo.submit(capture_settings=settings, quiet=True) ``` -------------------------------- ### Perform Security Investigation Workflow Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md This example outlines a typical workflow for security investigations using PyLookyloo. It combines various methods for analysis and data retrieval. ```python # This is a high-level representation. Specific methods would be chained. # capture_id = lookyloo.submit('malicious.com') # lookyloo.wait_for_completion(capture_id) # html = lookyloo.get_html(capture_id) # urls = lookyloo.get_urls(capture_id) # ips = lookyloo.get_ips(capture_id) ``` -------------------------------- ### CLI: Bash Function for Interactive Menu Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Provides an example of a bash function that creates an interactive menu for the lookyloo CLI. This enhances usability for command-line users. ```bash # Example bash function for interactive menu function lookyloo_menu() { echo "1. Query URL" echo "2. Search Hostname" read -p "Enter choice: " choice case $choice in 1) read -p "Enter URL: " url; lookyloo --query "$url" ;; 2) read -p "Enter Hostname: " hostname; lookyloo --search-hostname "$hostname" ;; *) echo "Invalid choice" esac } # To use: # lookyloo_menu ``` -------------------------------- ### Search for Captures Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md Provides an example of how to search for captures using the PyLookyloo library. Consult the API reference for available search and lookup methods. ```python # Example search (specific method depends on search criteria) # occurrences = lookyloo.get_url_occurrences('example.com') ``` -------------------------------- ### Comprehensive Error Handling Example Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Illustrates robust error handling using try-except blocks for various PyLookyloo errors. This ensures the application can gracefully manage potential issues during operations. ```python from lookyloo import Lookyloo, PyLookylooError, AuthError try: lookyloo = Lookyloo(api_key='invalid_key') lookyloo.submit('https://example.com') except AuthError as e: print(f'Authentication error: {e}') except PyLookylooError as e: print(f'PyLookyloo error: {e}') except Exception as e: print(f'An unexpected error occurred: {e}') ``` -------------------------------- ### Initialize Lookyloo Client Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Instantiate the Lookyloo client. Connect to the public instance or a custom instance with optional proxy and SSL verification settings. ```python from pylookyloo import Lookyloo # Connect to public instance lookyloo = Lookyloo() # Connect to custom instance with proxy lookyloo = Lookyloo( root_url='https://my-lookyloo.example.com', proxies={'https': 'https://proxy.internal:3128'}, verify='/etc/ssl/certs/ca-bundle.crt' ) ``` -------------------------------- ### Data Export Operations Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Provides examples for exporting captured data, including the complete capture as a zip file, a screenshot as a PNG, and the HTML content. Use these methods to retrieve specific artifacts from a capture. ```python from pylookyloo import Lookyloo from pathlib import Path lookyloo = Lookyloo() uuid = 'some-capture-uuid' # Download complete capture export = lookyloo.get_complete_capture(uuid) Path('capture.zip').write_bytes(export.getvalue()) # Get screenshot screenshot = lookyloo.get_screenshot(uuid) Path('screenshot.png').write_bytes(screenshot.getvalue()) # Get HTML html = lookyloo.get_html(uuid) Path('index.html').write_text(html.getvalue()) ``` -------------------------------- ### Connect to a Custom PyLookyloo Instance Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md Shows how to initialize the Lookyloo client with a specific instance URL. It also includes a check for instance connectivity. ```python # With custom instance URL lookyloo = Lookyloo(root_url='https://...') # Test connectivity if lookyloo.is_up: print('Instance is up!') else: print('Instance is down.') ``` -------------------------------- ### Custom Instance with Authentication Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Shows how to instantiate Lookyloo with custom settings, including authentication credentials. This is useful when connecting to a private or authenticated Lookyloo instance. ```python from lookyloo import Lookyloo lookyloo = Lookyloo(base_url='https://my.lookyloo.instance', api_key='my_secret_api_key') result = lookyloo.submit('https://www.example.com') print(result) ``` -------------------------------- ### Custom Instance with API Key Authentication Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Shows how to initialize Lookyloo with a custom root URL and authenticate using an API key. Use this pattern when connecting to a non-default Lookyloo instance that requires authentication. ```python from pylookyloo import Lookyloo, AuthError lookyloo = Lookyloo(root_url='https://internal-lookyloo.example.com') try: lookyloo.init_apikey(username='user', password='pass') config = lookyloo.get_user_config() except AuthError: print("Authentication failed") ``` -------------------------------- ### Get Favicons from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves potential favicon information from a capture. ```python def get_favicons(self, capture_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Connect to Custom Instance and Authenticate Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/examples.md Connect to a specific Lookyloo instance and authenticate using API keys. Checks instance reachability before proceeding. ```python from pylookyloo import Lookyloo, AuthError # Connect to internal instance lookyloo = Lookyloo( root_url='https://lookyloo.internal.example.com', useragent='MySecurityApp/1.0' ) # Check if instance is reachable if not lookyloo.is_up: print("Instance is unreachable") exit(1) # Authenticate with credentials try: lookyloo.init_apikey(username='analyst@example.com', password='secret') except AuthError as e: print(f"Authentication failed: {e}") exit(1) # Now you can use authenticated methods config = lookyloo.get_user_config() print(f"User config: {config}") ``` -------------------------------- ### Build Documentation with Sphinx Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Commands to build the HTML documentation for PyLookyloo using Sphinx. Navigate to the docs directory and run 'make html'. ```bash cd docs make html ``` -------------------------------- ### Instantiate Lookyloo with default public instance Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Connects to the default public Lookyloo instance at https://lookyloo.circl.lu/. No additional parameters are required. ```python from pylookyloo import Lookyloo lookyloo = Lookyloo() # Automatically connects to https://lookyloo.circl.lu/ ``` -------------------------------- ### Get All URLs from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves a dictionary of all URLs that were requested during a capture. ```python def get_urls(self, capture_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Access PyLookyloo Version Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Retrieve the installed version of the pylookyloo package using importlib.metadata. ```python from importlib.metadata import version print(version('pylookyloo')) # "1.39.2" ``` -------------------------------- ### Get All IP Addresses from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves a dictionary of all IP addresses that were contacted during a capture. ```python def get_ips(self, capture_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Get Statistics for a Specific Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Provides detailed statistics for a single capture, identified by its UUID. ```python def get_capture_stats(self, tree_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Configure PyLookyloo using .env files Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Set up PyLookyloo by loading configuration from a .env file using the dotenv library. Reads URL and API key from environment variables after loading the file. ```python # .env LOOKYLOO_URL=https://my-lookyloo.local LOOKYLOO_APIKEY=abc123xyz789 # main.py from dotenv import load_dotenv import os from pylookyloo import Lookyloo load_dotenv() lookyloo = Lookyloo(root_url=os.environ['LOOKYLOO_URL']) lookyloo.init_apikey(apikey=os.environ['LOOKYLOO_APIKEY']) ``` -------------------------------- ### Get HTTP Redirects from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves the initial HTTP redirect chain for a specified capture. ```python def get_redirects(self, capture_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Get Screenshot Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Download the screenshot of a capture as a PNG image. The result is returned as a BytesIO object. ```python screenshot = lookyloo.get_screenshot(uuid) with open('screenshot.png', 'wb') as f: f.write(screenshot.getvalue()) ``` -------------------------------- ### Enqueue URL via Command Line Source: https://github.com/lookyloo/pylookyloo/blob/main/README.md Use the `lookyloo` command to enqueue a URL for capture. Specify the URL to capture and optionally the Lookyloo instance URL and listing preference. ```bash usage: lookyloo [-h] [--url URL] --query QUERY Enqueue a URL on Lookyloo. optional arguments: -h, --help show this help message and exit --url URL URL of the instance (defaults to https://lookyloo.circl.lu/, the public instance). --query QUERY URL to enqueue. --listing Should the report be publicly listed. --redirects Get redirects for a given capture. The response is the permanent URL where you can see the result of the capture. ``` -------------------------------- ### Initialize PyLookyloo with API Key Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Initialize the Lookyloo client using an API key. All subsequent requests will include the Authorization header. ```python lookyloo.init_apikey(username='user@example.com', password='password') ``` -------------------------------- ### Get Third-Party Module Responses Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve responses from third-party modules that have been run on a capture using its UUID. ```python lookyloo.get_modules_responses(tree_uuid) ``` -------------------------------- ### Get Instance-Wide Statistics Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves overall statistics for the Lookyloo instance, such as the total number of captures and hostnames. ```python def get_stats(self) -> dict[str, Any] ``` -------------------------------- ### Bulk Upload from Directory Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates how to upload multiple files from a local directory for analysis. This is useful for processing a collection of related artifacts. ```python from lookyloo import Lookyloo lookyloo = Lookyloo() # Assume 'path/to/artifacts' contains files to upload results = lookyloo.upload_directory('path/to/artifacts') print(results) ``` -------------------------------- ### Get Storage State Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Access the complete storage state of the capture, including localStorage, IndexedDB, and sessionStorage. ```python lookyloo.get_storage(capture_uuid) ``` -------------------------------- ### Get Cookies Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve the complete list of cookies captured during the session. The cookies are returned as a list of dictionaries. ```python lookyloo.get_cookies(capture_uuid) ``` -------------------------------- ### Basic PyLookyloo Usage Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/README.md Demonstrates basic usage of the Lookyloo client to submit a URL for capture and print the resulting UUID. Ensure the Lookyloo client is initialized. ```python from pylookyloo import Lookyloo lookyloo = Lookyloo() uuid = lookyloo.submit(url='https://example.com', quiet=True) print(f"Capture UUID: {uuid}") ``` -------------------------------- ### Get Downloaded Data Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve any data downloaded during the capture process. The data is returned as a BytesIO object. ```python lookyloo.get_data(capture_uuid) ``` -------------------------------- ### Import Main Lookyloo Class Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Import the primary client class from the pylookyloo package. ```python # Import main class from pylookyloo import Lookyloo ``` -------------------------------- ### Get Capture Info Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve metadata for a capture, including the original URL, timestamp, and user agent. ```python lookyloo.get_info(tree_uuid) ``` -------------------------------- ### Get Takedown Information (Email List) Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve only the email addresses for takedown requests for a given capture UUID. ```python def get_takedown_information(self, capture_uuid: str, filter_contacts: Literal[True]) -> list[str]: ... ``` ```python # Get email list only emails = lookyloo.get_takedown_information(uuid, filter_contacts=True) ``` -------------------------------- ### Instantiate Lookyloo with a custom instance URL Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Connects to a specific Lookyloo instance by providing its root URL. The scheme is auto-added if omitted, and a trailing slash is also auto-added. ```python lookyloo = Lookyloo(root_url='https://my-lookyloo.internal.example.com') ``` -------------------------------- ### Initialize API Authentication with Credentials Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Initialize API authentication using username and password. This is required for subsequent authenticated requests. ```python # Using credentials lookyloo.init_apikey(username='user@example.com', password='password123') ``` -------------------------------- ### Get User Configuration Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve the server configuration enforced for the authenticated user. Requires prior API authentication. ```python lookyloo.get_user_config() ``` -------------------------------- ### Get Comparable Data from Capture Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Extracts data from a capture that is suitable for comparison with other captures using the `compare_captures` method. ```python def get_comparables(self, tree_uuid: str) -> dict[str, Any] ``` -------------------------------- ### Submit with Settings Dictionary Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Submit a capture using a pre-defined dictionary of settings, including URL, browser, and viewport. ```python settings = { 'url': 'https://example.com', 'browser': 'firefox', 'viewport': {'width': 1920, 'height': 1080} } capture_url = lookyloo.submit(capture_settings=settings) ``` -------------------------------- ### Define CLI Entry Point Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Defines the 'lookyloo' command-line interface entry point in the pyproject.toml file. ```toml [project.scripts] lookyloo = 'pylookyloo:main' ``` -------------------------------- ### Configure PyLookyloo using os.environ Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/configuration.md Initialize PyLookyloo by reading configuration values like root URL and user agent from environment variables. Optionally initializes with an API key if provided. ```python import os from pylookyloo import Lookyloo lookyloo = Lookyloo( root_url=os.environ.get('LOOKYLOO_URL', 'https://lookyloo.circl.lu'), useragent=os.environ.get('LOOKYLOO_USERAGENT') ) if os.environ.get('LOOKYLOO_APIKEY'): lookyloo.init_apikey(apikey=os.environ['LOOKYLOO_APIKEY']) ``` -------------------------------- ### get_recent_captures Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Get UUIDs of the most recent captures. Optionally filter by a timestamp to retrieve captures newer than a specified point in time. ```APIDOC ## get_recent_captures ### Description Get UUIDs of most recent captures, optionally filtered by timestamp. ### Method GET (Assumed, as it retrieves data) ### Endpoint `/captures/recent` (Assumed based on method name) ### Parameters #### Query Parameters - **timestamp** (str | datetime | float | None) - Optional - Oldest timestamp to consider (Unix epoch float, datetime, or string). Defaults to None. ### Response #### Success Response (200) - **capture_uuids** (list[str]) - List of capture UUIDs. ### Request Example ```python from datetime import datetime, timedelta # Get captures from last hour one_hour_ago = datetime.now() - timedelta(hours=1) recent = lookyloo.get_recent_captures(timestamp=one_hour_ago) ``` ``` -------------------------------- ### Configure PyLookyloo with Custom SSL Certificate Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md Shows how to specify a custom CA bundle file path for SSL certificate verification when initializing the Lookyloo client. ```python # With custom SSL certificate verification lookyloo = Lookyloo(verify='/path/to/ca-bundle.pem') ``` -------------------------------- ### Get Capture UUIDs by Category Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Returns UUIDs for captures belonging to a specific category or all categorized captures if no category is specified. ```python def get_categories_captures(self, category: str | None = None) -> list[str] | dict[str, list[str]] | None ``` -------------------------------- ### Direct Import from API (Not Recommended) Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/modules.md Demonstrates importing the Lookyloo class directly from the internal api module. This is functional but not the recommended approach. ```python # Avoid importing from api directly from pylookyloo.api import Lookyloo # Works but not recommended # Preferred from pylookyloo import Lookyloo # Recommended ``` -------------------------------- ### Batch Capture from File Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Demonstrates how to perform a batch capture of URLs listed in a file and track the results. This is efficient for processing multiple URLs simultaneously. ```python from lookyloo import Lookyloo lookyloo = Lookyloo() with open('urls.txt', 'r') as f: urls = f.readlines() results = lookyloo.submit_batch(urls) for url, result in results.items(): print(f'{url}: {result}') ``` -------------------------------- ### Error Handling: Instance Unreachable Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Demonstrates the error message when the specified Lookyloo instance URL is unreachable. ```bash # Instance down $ lookyloo --url https://unreachable.local --query https://example.com Unable to reach https://unreachable.local/. Is the server up? ``` -------------------------------- ### Get Takedown Information (Raw Contacts) Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve full contact information dictionaries for takedown requests for a given capture UUID. ```python def get_takedown_information(self, capture_uuid: str, filter_contacts: Literal[False] = False) -> list[dict[str, Any]]: ... ``` ```python # Get raw contact info contacts = lookyloo.get_takedown_information(uuid, filter_contacts=False) ``` -------------------------------- ### Get Recent Capture UUIDs Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves a list of UUIDs for recent captures. Optionally filters captures older than a specified timestamp. ```python def get_recent_captures(self, timestamp: str | datetime | float | None = None) -> list[str] ``` -------------------------------- ### Lookyloo CLI Main Menu Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md A shell script demonstrating the interactive menu for common Lookyloo CLI operations. ```bash while true; do echo "Lookyloo CLI Menu" echo "1. Capture a URL" echo "2. Search by URL" echo "3. Search by hostname" echo "4. Get redirects" echo "5. Exit" read -p "Choose: " choice case $choice in 1) read -p "URL: " url read -p "Make public? (y/n): " public [ "$public" = "y" ] && lookyloo --query "$url" --listing || lookyloo --query "$url" ;; 2) read -p "Search URL: " url lookyloo --search-url "$url" | python3 -m json.tool ;; 3) read -p "Hostname: " hostname lookyloo --search-hostname "$hostname" | python3 -m json.tool ;; 4) read -p "Capture UUID: " uuid lookyloo --redirects "$uuid" | python3 -m json.tool ;; 5) exit 0 ;; esac echo "" done ``` -------------------------------- ### Get Hashes of Capture Response Bodies Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieves hashes for all response bodies within a capture. Optionally include associated URLs. ```python def get_hashes(self, capture_uuid: str, algorithm: str = 'sha512', hashes_only: bool = True) -> StringIO ``` -------------------------------- ### Get Rendered HTML Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/api-reference.md Retrieve the rendered HTML content of the page as it appeared in the browser after loading. The content is returned as a StringIO object. ```python html = lookyloo.get_html(uuid) content = html.getvalue() ``` -------------------------------- ### Configure PyLookyloo with HTTP Proxy Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/INDEX.md Demonstrates how to configure the Lookyloo client to use an HTTP or SOCKS proxy. This is useful for network configurations that require a proxy. ```python # With HTTP proxy lookyloo = Lookyloo(proxies={'https': 'https://...'}) ``` -------------------------------- ### Try/Catch Example for PyLookylooError Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Shows how to catch the base `PyLookylooError` exception, which is the parent class for most PyLookyloo-specific errors. This is useful for general error handling. ```python from lookyloo import Lookyloo, PyLookylooError try: lookyloo = Lookyloo() # Simulate an error, e.g., invalid URL or network issue lookyloo.submit('invalid-url') except PyLookylooError as e: print(f'A PyLookyloo error occurred: {e}') ``` -------------------------------- ### Prevent AuthError by Initializing API Key Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/errors.md Demonstrates the recommended practice of initializing the API key using `init_apikey()` before calling authenticated methods to prevent AuthError. ```python lookyloo.init_apikey(apikey='your_api_key') # Now authenticated methods are available config = lookyloo.get_user_config() ``` -------------------------------- ### Parse JSON Output with Python Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Examples of using Python to parse and extract data from JSON output generated by Lookyloo CLI commands. ```bash # Get count lookyloo --search-url "tracking" | python3 -c "import sys, json; print(json.load(sys.stdin).get('total', 0))" ``` ```bash # Extract specific field lookyloo --redirects {uuid} | python3 -c "import sys, json; data = json.load(sys.stdin); print(data.get('url', 'N/A'))" ``` -------------------------------- ### Search and Analysis Workflow Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/MANIFEST.txt Illustrates a typical workflow involving searching for previously captured URLs and then analyzing the results. This demonstrates the retrieval and comparison capabilities. ```python from lookyloo import Lookyloo lookyloo = Lookyloo() search_results = lookyloo.search_url('example.com') if search_results: capture_id = search_results[0]['capture_id'] info = lookyloo.get_info(capture_id) print(info) # Example analysis (comparison) if len(search_results) > 1: comparison = lookyloo.compare_captures(search_results[0]['capture_id'], search_results[1]['capture_id']) print(comparison) ``` -------------------------------- ### Display Help Message Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/cli-reference.md Shows the help message for the lookyloo command, useful for understanding available options and arguments. This command uses the default public instance if no --url is specified. ```bash lookyloo --help ``` -------------------------------- ### Catch Requests Library Errors Source: https://github.com/lookyloo/pylookyloo/blob/main/_autodocs/errors.md Provides an example of catching common exceptions from the `requests` library, such as ConnectionError and HTTPError, when interacting with a Lookyloo instance. ```python import requests from pylookyloo import Lookyloo lookyloo = Lookyloo('https://unreachable-instance.com') try: if not lookyloo.is_up: print("Instance is down") else: status = lookyloo.get_status('some-uuid') except requests.exceptions.ConnectionError: print("Network error contacting Lookyloo") except requests.exceptions.HTTPError as e: print(f"HTTP error: {e.response.status_code}") ```