Python · Web Automation

Bulk-Save Shared Terabox Links with a Selenium Scraper and GUI

TL;DR

A scraper collects titles and share links into a manifest, then a GUI automation logs in manually and saves every link to a Terabox folder you choose - for content you are authorised to copy.

Updated 1 min read

PythonSeleniumTkinterwebdriver-managerXPath

Download source (ZIP)v1.0.0 · 4 files · 31 KB · MIT license

Abstract

The problem

Resource sites list hundreds of Download buttons that lead to Terabox shared links, and Terabox has no bulk-save. Saving 100 files by hand takes hours.

The solution

Stage 1 scrapes titles and links into a manifest; stage 2 is a GUI automation engine that, after a manual login, visits each link and saves it into a target folder.

The result

Hours of repetitive clicking reduced to a single run with real-time progress logging.

Input & Output

Input
  • Target resource website (stage 1)
  • terabox_links.txt – one URL per line (stage 2)
Output
  • Every shared link saved into your chosen Terabox folder
Optional output
  • Human-readable "{Title} - {URL}" list
  • Live GUI log of successes, timeouts and failures

System Diagram

How It Works

Dynamic loading

Waits for JavaScript so links missing from initial HTML are captured.

Heuristic pairing

Regex finds numbered titles and pairs each with the next Download button.

Manual-to-auto handover

You log in by hand, then the script takes over – no captcha fighting.

Absolute XPaths

Precisely target Save, folder, Yes and the success message.

State verification

Checks the link identifier (surl) so dead or redirected links do not crash the run.

Error resilience

Falls back to JavaScript clicks when overlays intercept a normal click.

Configuration

OptionPurpose
Links fileterabox_links.txt – only lines starting with http are processed.
Credentials fileOptional credentials.txt (email,password); manual login is recommended.
target_folder_xpathPoints at the destination folder in the Save dialog (tuned to "TestUpload").

How to Run

Step 1 – extract links
python url_finder_2.py
Step 2 – open the control panel
python tera_link_saver_4.py
Step 3
# Start Browser → log in manually → Start Saving

Source Code

link_saver.pypreview
import time
import logging
import re
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import TimeoutException, NoSuchElementException, ElementClickInterceptedException, StaleElementReferenceException
from webdriver_manager.chrome import ChromeDriverManager
import tkinter as tk
from tkinter import filedialog, messagebox, scrolledtext
import threading
import os # Import os module for file path handling

# --- Configuration ---
# Define default folder path within your Terabox account where files will be saved
DEFAULT_SAVE_FOLDER_PATH = "/My Saved Files/" # Example path - Not used directly with fixed XPaths
# Path to the text file containing shared links - Updated for your Windows path
LINKS_FILE_PATH = "terabox_links.txt" # Raw string for Windows path
# Path to the text file containing your Terabox credentials (optional, currently manual login is primary)
CREDENTIALS_FILE_PATH = "credentials.txt" # Raw string for Windows path - Format: email,password

# --- Logging Setup ---
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

def extract_link_identifier(url):
    """
    Extracts the unique identifier from a Terabox shared link URL.
    Handles various formats like:
    - https://teraboxlink.com/s/1YOUR_SURL_ID
    - https://www.1024tera.com/sharing/link?surl=YOUR_SURL_ID
    - https://www.terabox.app/sharing/link?surl=YOUR_SURL_ID
    """
    # Pattern 1: /s/1 followed by the ID (or /s/ followed by the ID)
    # Example: .../s/1YOUR_SURL_ID or .../s/YOUR_SURL_ID
    match1 = re.search(r'/s/(?:1)?([a-zA-Z0-9_-]+)', url)
    if match1:
        return match1.group(1)

    # Pattern 2: surl= followed by the ID
    # Example: .../sharing/link?surl=YOUR_SURL_ID
    match2 = re.search(r'surl=([a-zA-Z0-9_-]+)', url)
    if match2:
        return match2.group(1)

    # Pattern 3: /s/ followed by the ID (alternative check if 1 doesn't work)
    # Example: .../s/YOUR_SURL_ID
    match3 = re.search(r'/s/([a-zA-Z0-9_-]+)', url)
    if match3:
        return match3.group(1)

    # If no pattern matches, return the original URL or None
    logger.warning(f"Could not extract identifier from URL: {url}")
    return None # Returning None if no identifier is found


class TeraboxSaver:

… 362 more lines - loading the full file

Download source (ZIP)v1.0.0 · 4 files · 31 KB · MIT license

Released under the MIT license. Free to use, modify and share.

Impact & Benefits

Replaces hours of manual clicking with one execution.
Anti-bot friendly through the manual login phase.
Live progress such as "Successfully saved link 5/100".

Frequently Asked Questions

Can Terabox save many shared links at once?

Not natively. These scripts automate the repetitive clicks: open each link, press Save, pick the folder and confirm.

Why do I log in manually?

Manual login avoids captchas and two-factor prompts, then the script takes over for the repetitive part.

Is this allowed?

Use it only for content you own or may copy, and follow Terabox and the source site's terms of service.

Related

© 2026 Thuyavan Sivarasa. Script code is MIT licensed.