Skip to content

主要步骤为以下:

  1. 获取页面内所有视频链接
  2. 存入 urls.txt 文件
  3. 执行 main.py 脚本

获取所有链接

打开目标视频集合页面,使用console输入脚本来收集网址

以下用来获取,滚动进行收集


(function() {
  const allHrefs = new Set();
  
  // --- 新增:创建 UI 提示框 ---
  const indicator = document.createElement('div');
  Object.assign(indicator.style, {
    position: 'fixed',
    top: '20px',
    right: '20px',
    padding: '10px 16px',
    backgroundColor: 'rgba(0, 0, 0, 0.8)',
    color: '#fff',
    borderRadius: '8px',
    zIndex: '999999',
    fontSize: '14px',
    boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
    pointerEvents: 'none',
    transition: 'transform 0.2s ease',
    fontFamily: 'sans-serif',
    border: '1px solid #444'
  });
  indicator.innerHTML = '已采集: <span style="color: #4dabf7; font-weight: bold;">0</span> 个链接';
  document.body.appendChild(indicator);

  const updateUI = (count) => {
    indicator.querySelector('span').innerText = count;
    // 简单的动画反馈
    indicator.style.transform = 'scale(1.05)';
    setTimeout(() => indicator.style.transform = 'scale(1)', 100);
  };

  const collect = () => {
    const anchors = document.querySelectorAll('a[href*="/images/"], a[href*="/posts/"], a[href*="/models/"]');
    const prevSize = allHrefs.size;
    
    anchors.forEach(a => {
      try {
        const url = new URL(a.href);
        const cleanUrl = url.origin + url.pathname;
        allHrefs.add(cleanUrl);
      } catch(e) {}
    });

    if (allHrefs.size !== prevSize) {
      updateUI(allHrefs.size);
    }
  };

  const observer = new MutationObserver(collect);
  observer.observe(document.body, { childList: true, subtree: true });

  collect();

  window.__collectedLinks = allHrefs;
  window.__stopCollection = () => {
    observer.disconnect();
    if (document.body.contains(indicator)) {
        document.body.removeChild(indicator);
    }
    
    const result = Array.from(window.__collectedLinks).join('\n');
    console.log('%c采集完成!已复制到剪贴板。', 'color: green; font-weight: bold;');
    
    const textArea = document.createElement("textarea");
    textArea.value = result;
    document.body.appendChild(textArea);
    textArea.select();
    document.execCommand('copy');
    document.body.removeChild(textArea);
    
    delete window.__collectedLinks;
    delete window.__stopCollection;
    return `共采集 ${result.split('\n').filter(Boolean).length} 个链接`;
  };

  console.log('监控中... 页面右上角已开启计数器。');
  console.log('完成后请在控制台输入: window.__stopCollection()');
})();

用来停止 window.__stopCollection();

存入URLS.TXT

脚本会在停止后复制到剪切板,你只需要创建文本文件后粘贴

最后执行python脚本

视频就会下载到目录里面