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 page documents all configuration options available in Lightshot Scrape, including command-line arguments, file paths, and required dependencies.

Command-line arguments

The Lightshot Scrape CLI accepts command-line arguments to control its behavior.
The main.py script is currently a work in progress and does not have full implementation. For direct usage, use singleImage.py which contains the core scraping functionality.

Mode selection

-m, --mode
string
required
Specifies the operating mode for the scraper.Accepted values:
  • en - Single image mode (scrapes one image)
  • loop - Loop mode (continuously scrapes images)
Example:
python main.py -m en
python main.py --mode loop

Usage examples

python main.py -m en
If you run the script without specifying the mode argument, the program will exit with an error message: “Ange inställning (‘-m en’ eller ‘-m loop’)“

Argument parsing

The tool uses Python’s getopt module to parse command-line arguments:
import getopt
import sys

nameargv = sys.argv[1:]

try:
    opts = getopt.getopt(nameargv, "m:", ["mode ="])
    print(opts)
except:
    print("Ange inställning ('-m en' eller '-m loop')")
    sys.exit(2)

File paths

Image save path

By default, scraped images are saved to the Windows Pictures folder.
imgpath
string
The directory where downloaded images will be saved.Default value: C:\Users\%username%\Pictures\Saved PicturesNote: The %username% variable should be expanded by the system to the current user’s username.

Configuration in code

# Default save path
imgpath = "C:\\Users\\%username%\\Pictures\\Saved Pictures"
In the current implementation, there is commented-out code that would allow users to specify a custom save path via input. This feature is currently disabled:
# Commented out in current version:
# imgpath = input("Var ska bilderna sparas? (Enter för att spara i Sparade Bilder)").strip() 
#          or "C:\\Users\\%username%\\Pictures\\Saved Pictures"

Dependencies

Lightshot Scrape requires several Python packages to function properly.

Required packages

Purpose: Bypasses Cloudflare protection on Lightshot pagesUsage in code:
import cloudscraper

scraper = cloudscraper.create_scraper()
site = scraper.get(link).text
Why it’s needed: Lightshot uses Cloudflare protection, which blocks regular requests. Cloudscraper mimics a real browser to bypass this protection.Installation:
pip install cloudscraper
Purpose: Parses HTML to extract image URLsUsage in code:
from bs4 import BeautifulSoup

soup = BeautifulSoup(site, 'html.parser')
img = soup.find_all('img')[0]
img = img['src']
Why it’s needed: Extracts the image source URL from the Lightshot page HTML by finding <img> tags.Installation:
pip install beautifulsoup4
Purpose: HTTP library for making web requestsUsage in code:
import requests
Why it’s needed: Used as a dependency for cloudscraper and for downloading images.Installation:
pip install requests

Standard library modules

The following Python standard library modules are also used (no installation required):
  • random - Generates random characters for URL creation
  • string - Provides character sets (ascii_lowercase, ascii_uppercase, digits)
  • time - Time-related functions
  • os - Operating system interface
  • sys - System-specific parameters and functions
  • getopt - Command-line argument parser

Complete dependency list

Create a requirements.txt file with these dependencies:
requirements.txt
cloudscraper>=1.2.58
beautifulsoup4>=4.9.3
requests>=2.25.1
Install all dependencies with:
pip install -r requirements.txt

Environment requirements

Python version

Python 3.6 or higher recommended

Operating system

Designed for Windows (default save path uses Windows directory structure)

Internet connection

Required to access Lightshot URLs and download images

Disk space

Sufficient space in the save directory for downloaded images

Cloudscraper instance

The tool creates cloudscraper instances in multiple locations:

Global instance

Created at module level in both main.py and singleImage.py:
scraper = cloudscraper.create_scraper()

Local instance

The ImageHandler function creates its own instance:
def ImageHandler(link):
    scraper = cloudscraper.create_scraper()
    site = scraper.get(link).text
    # ...
Creating a new scraper instance for each request ensures fresh sessions and helps avoid rate limiting or blocking.