Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/osctorand/lightshotscrape/llms.txt

Use this file to discover all available pages before exploring further.

This reference documents all core functions in the Lightshot Scrape Python CLI tool. These functions handle URL generation, image extraction, and verification.

ImageLinkGenerator

Generates a random Lightshot URL by creating a random 12-character string.

Signature

ImageLinkGenerator() -> str

Parameters

This function takes no parameters.

Returns

A random Lightshot URL in the format https://prnt.sc/{random_string} where random_string is a 12-character combination of uppercase letters, lowercase letters, and digits.

Implementation details

The function generates a random 12-character string using:
  • Lowercase letters (a-z)
  • Uppercase letters (A-Z)
  • Digits (0-9)
The random string is appended to https://prnt.sc/ to create a valid Lightshot URL.

Example

from lightshotscrape.singleImage import ImageLinkGenerator

# Generate a random Lightshot URL
link = ImageLinkGenerator()
print(link)
# Output: https://prnt.sc/Bz9iVlFAetPw (example)

ImageHandler

Extracts the actual image URL from a Lightshot page by scraping the HTML and finding the image source.

Signature

ImageHandler(link: str) -> str | None

Parameters

The Lightshot URL to scrape (e.g., https://prnt.sc/abc123)

Returns

img
string | None
The direct image URL extracted from the Lightshot page, or None if an error occurs. The image URL typically points to the CDN where the actual image is hosted.

Implementation details

The function:
  1. Creates a cloudscraper instance to bypass Cloudflare protection
  2. Fetches the HTML content of the Lightshot page
  3. Parses the HTML using BeautifulSoup
  4. Finds the first <img> tag and extracts its src attribute
  5. Returns the image URL or prints an error if something fails

Example

from lightshotscrape.singleImage import ImageHandler, ImageLinkGenerator

# Generate a random link and extract the image URL
link = ImageLinkGenerator()
img_url = ImageHandler(link)

if img_url:
    print(f"Image URL: {img_url}")
else:
    print("Failed to extract image")

Dependencies

  • cloudscraper: Used to bypass Cloudflare protection on Lightshot pages
  • BeautifulSoup: Parses HTML to extract image tags
  • requests: HTTP library (used indirectly through cloudscraper)
The function catches all exceptions and prints them to stdout, but does not raise them. Make sure to check if the return value is None before using it.

ImageVerifier

Verifies the validity of an image URL (currently a placeholder function).

Signature

ImageVerifier(img: str) -> None

Parameters

img
string
required
The image URL to verify

Returns

result
None
Currently returns None as this function is not yet implemented.

Implementation details

This function is currently a placeholder with no implementation (pass statement). It does not perform any verification.

Example

from lightshotscrape.singleImage import ImageVerifier

img_url = "https://example.com/image.png"
ImageVerifier(img_url)
# Currently does nothing
This function could be implemented to:
  • Check if the image URL is accessible (HTTP 200 status)
  • Verify the content type is an image
  • Check if the image is a valid image file (not a 404 placeholder)
  • Validate image dimensions or file size
  • Filter out Lightshot’s default “image not found” placeholder