吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5057|回复: 41
收起左侧

[其他原创] 淘宝图片提取工具【买家秀图片下载工具】

  [复制链接]
wk312 发表于 2025-6-21 16:19
本帖最后由 wk312 于 2025-6-21 16:21 编辑

本工具为淘宝图片链接提取,现在的淘宝PC版的图片都带有webp格式,其原理就是去除第一个jpg、png、gif后缀之后的内容,从而得到原图,使用场景如淘宝的评价图片,直接复制或者另存为保存的文件后缀为webp,并不能直接使用,本工具可以批量输入图片链接提取图片。

image.png
使用方法
打开需要复制的图片,复制图片链接

image.png

输入到文本框,点击提取图片即可

image.png
以下为完整代码
[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>淘宝图片提取助手</title>
    <style>
        :root {
            --primary-color: #fd5e02;
            --bg-color: #f8f9fa;
            --card-color: #ffffff;
            --border-color: #e9ecef;
            --text-color: #333333;
            --button-hover: #e65500;
            --error-color: #ff4d4f;
        }
        
        body {
            font-family: 'Segoe UI', 'PingFang SC', sans-serif;
            max-width: 800px;
            margin: 20px auto;
            padding: 20px;
            background-color: var(--bg-color);
            color: var(--text-color);
        }
        
        .container {
            background: var(--card-color);
            padding: 25px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        }
        
        h2 {
            color: var(--text-color);
            border-bottom: 2px solid var(--primary-color);
            padding-bottom: 8px;
            margin-bottom: 20px;
            font-size: 22px;
            font-weight: 600;
        }
        
        .input-area {
            margin-bottom: 25px;
        }
        
        textarea {
            width: 100%;
            height: 120px;
            padding: 12px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 14px;
            line-height: 1.5;
            resize: vertical;
            transition: border-color 0.2s;
            outline: none;
        }
        
        textarea:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(253, 94, 2, 0.1);
        }
        
        button {
            background-color: var(--primary-color);
            color: white;
            padding: 10px 18px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            margin-right: 10px;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        button:hover {
            background-color: var(--button-hover);
            transform: translateY(-1px);
        }
        
        button:active {
            transform: translateY(0);
        }
        
        .image-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 18px;
            margin-top: 25px;
        }
        
        .image-item {
            border: 1px solid var(--border-color);
            border-radius: 10px;
            padding: 14px;
            text-align: center;
            background: var(--card-color);
            transition: all 0.2s;
            overflow: hidden;
            position: relative;
        }
        
        .image-item:hover {
            box-shadow: 0 6px 16px rgba(0,0,0,0.08);
            transform: translateY(-2px);
        }
        
        img {
            max-width: 100%;
            height: auto;
            margin-bottom: 12px;
            border-radius: 6px;
            object-fit: cover;
            max-height: 200px;
        }
        
        p {
            margin: 0;
            padding: 0;
            font-size: 13px;
            color: #666;
            margin-bottom: 12px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        
        .open-btn {
            display: inline-block;
            background-color: var(--primary-color);
            color: white;
            padding: 8px 14px;
            border-radius: 6px;
            text-decoration: none;
            font-size: 13px;
            transition: all 0.2s;
            width: 80%;
            cursor: pointer;
            margin-bottom: 8px;
        }
        
        .open-btn:hover {
            background-color: var(--button-hover);
            transform: translateY(-1px);
        }
        
        .open-btn:active {
            transform: translateY(0);
        }
        
        .download-btn {
            display: inline-block;
            background-color: #4CAF50;
            color: white;
            padding: 8px 14px;
            border-radius: 6px;
            text-decoration: none;
            font-size: 13px;
            transition: all 0.2s;
            width: 80%;
            cursor: pointer;
        }
        
        .download-btn:hover {
            background-color: #45a049;
            transform: translateY(-1px);
        }
        
        .download-btn:active {
            transform: translateY(0);
        }
        
        /* 响应式设计 */
        @media (max-width: 600px) {
            body {
                padding: 10px;
            }
            
            .container {
                padding: 18px;
            }
            
            button {
                width: 100%;
                margin-bottom: 10px;
            }
            
            .image-list {
                grid-template-columns: 1fr;
            }
        }
        
        .error-message {
            color: var(--error-color);
            font-size: 14px;
            margin: 10px 0;
            padding: 8px 12px;
            background-color: rgba(255, 77, 79, 0.05);
            border-radius: 4px;
            display: flex;
            align-items: center;
        }
        
        .error-message svg {
            margin-right: 6px;
            width: 16px;
            height: 16px;
        }
        
        .notice {
            margin: 15px 0;
            padding: 12px;
            background-color: rgba(253, 94, 2, 0.05);
            border-radius: 6px;
            border-left: 4px solid var(--primary-color);
            color: #666;
            font-size: 14px;
        }
        
        .toast {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 10px 16px;
            border-radius: 4px;
            font-size: 14px;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .toast.show {
            opacity: 1;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>淘宝图片提取助手</h2>
        
        <div class="notice">
            <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="float: left; margin-right: 8px;">
                <circle cx="12" cy="12" r="10"></circle>
                <line x1="12" y1="16" x2="12" y2="12"></line>
                <line x1="12" y1="8" x2="12.01" y2="8"></line>
            </svg>
            <p>提示:由于淘宝图片设置了防盗链,直接下载可能失败。建议使用"在新窗口打开图片"功能,并在浏览器中右键保存图片。</p>
        </div>
        
        <div class="input-area">
            <textarea id="urlInput" placeholder="请输入淘宝图片链接(每行一个)"></textarea>
            <br>
            <button>
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 6px;">
                    <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path>
                    <rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect>
                    <line x1="12" y1="8" x2="12" y2="16"></line>
                    <line x1="16" y1="12" x2="12" y2="12"></line>
                    <line x1="8" y1="12" x2="8" y2="12"></line>
                </svg>
                提取图片
            </button>
            <button>
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 6px;">
                    <path d="M21 4H8l-7 8 7 8h13a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"></path>
                    <line x1="18" y1="9" x2="12" y2="15"></line>
                    <line x1="12" y1="9" x2="18" y2="15"></line>
                </svg>
                清空结果
            </button>
        </div>
        <div id="imageContainer" class="image-list"></div>
        <div id="errorContainer"></div>
    </div>
    
    <!-- 提示框 -->
    <div id="toast" class="toast">下载操作已触发</div>

    <script>
        function extractImages() {
            const urlInput = document.getElementById('urlInput');
            const imageContainer = document.getElementById('imageContainer');
            const errorContainer = document.getElementById('errorContainer');
            
            imageContainer.innerHTML = ''; // 清空旧结果
            errorContainer.innerHTML = ''; // 清空错误信息
            
            const urls = urlInput.value.trim().split('\n');
            let errorCount = 0;
            
            urls.forEach(url => {
                if (!url.trim()) return; // 跳过空行
                
                try {
                    // 优化正则表达式,支持更多图片格式并只保留第一个扩展名
                    const cleanedUrl = url.replace(/\.(jpg|jpeg|png|gif)(\?.*|#.*|_.*|$)/i, '.$1');
                    
                    // 创建图片元素
                    const imgDiv = document.createElement('div');
                    imgDiv.className = 'image-item';
                    imgDiv.innerHTML = `
                        <img src="${cleanedUrl}" alt="提取的图片">
                        <p>原始链接:${url}</p>
                        <p>处理后链接:${cleanedUrl}</p>
                        <button class="open-btn">
                            <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 4px;">
                                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
                                <polyline points="15 3 21 3 21 9"></polyline>
                                <line x1="10" y1="14" x2="21" y2="3"></line>
                            </svg>
                            在新窗口打开图片
                        </button>
                        <button class="download-btn">
                            <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 4px;">
                                <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                                <polyline points="7 10 12 15 17 10"></polyline>
                                <line x1="12" y1="15" x2="12" y2="3"></line>
                            </svg>
                            尝试下载图片
                        </button>
                    `;
                    imageContainer.appendChild(imgDiv);
                } catch (error) {
                    errorCount++;
                    // 只显示第一个错误,避免太多错误信息
                    if (errorCount === 1) {
                        const errorDiv = document.createElement('div');
                        errorDiv.className = 'error-message';
                        errorDiv.innerHTML = `
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                <circle cx="12" cy="12" r="10"></circle>
                                <line x1="12" y1="8" x2="12" y2="12"></line>
                                <line x1="12" y1="16" x2="12.01" y2="16"></line>
                            </svg>
                            处理链接时出错:${url}
                        `;
                        errorContainer.appendChild(errorDiv);
                    }
                }
            });
            
            // 如果没有提取到任何图片,显示提示
            if (imageContainer.children.length === 0) {
                const emptyDiv = document.createElement('div');
                emptyDiv.className = 'image-item';
                emptyDiv.innerHTML = `
                    <div style="padding: 20px; color: #999;">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin: 0 auto 10px; display: block;">
                            <circle cx="12" cy="12" r="10"></circle>
                            <line x1="12" y1="16" x2="12" y2="12"></line>
                            <line x1="12" y1="8" x2="12.01" y2="8"></line>
                        </svg>
                        没有找到有效的图片链接
                    </div>
                `;
                imageContainer.appendChild(emptyDiv);
            }
        }

        // 从URL中提取文件名
        function getFileName(url) {
            const parts = url.split('/');
            return parts[parts.length - 1].split('?')[0].split('#')[0];
        }

        // 清空结果
        function clearImages() {
            document.getElementById('urlInput').value = '';
            document.getElementById('imageContainer').innerHTML = '';
            document.getElementById('errorContainer').innerHTML = '';
        }
        
        // 在新窗口打开图片链接
        function openInNewTab(url) {
            window.open(url, '_blank');
        }
        
        // 下载图片
        function downloadImage(url, filename) {
            showToast("正在尝试下载...");
            
            fetch(url, {
                method: 'GET',
                mode: 'cors',
                headers: {
                    'Referer': 'https://item.taobao.com/' // 设置淘宝商品页面的Referer,可能有助于绕过防盗链
                }
            })
            .then(response => {
                if (!response.ok) {
                    throw new Error(`HTTP error! status: ${response.status}`);
                }
                return response.blob();
            })
            .then(blob => {
                // 创建下载链接
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url;
                a.download = filename;
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
                URL.revokeObjectURL(url);
                showToast("下载已触发,请检查浏览器下载提示");
            })
            .catch(error => {
                console.error('下载图片时出错:', error);
                showToast("下载失败,请尝试使用'在新窗口打开'功能");
            });
        }
        
        // 显示提示框
        function showToast(message) {
            const toast = document.getElementById('toast');
            toast.textContent = message;
            toast.classList.add('show');
            
            setTimeout(() => {
                toast.classList.remove('show');
            }, 3000);
        }
    </script>
</body>
</html>


源码下载:https://wkai.lanzoue.com/inHM62ywfs2j

免费评分

参与人数 3吾爱币 +9 热心值 +2 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
38342175 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
lyrong2008 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| wk312 发表于 2025-7-21 14:25
这个工具主要的应用场景就是做淘宝平台的商家,给产品做买家秀的时候,一般找同款竞品的,但是这个图片操作一般保存的webp格式,很多人并懂这些东西,你发给别人,别人下载后传不了,所有就做了这么一个小工具,就是为了方便那些对这些东西不是很懂的人。
paoxueyuan 发表于 2025-6-22 19:28
我到现在都没有理解这个工具的意义,网页版淘宝都可以直接复制图片了,不要这做什么呢 ,而且吧,在开发者工具中,人家这个feedPicPathList 字段中都有直接的源图了,要费那个劲啊,只要解决这个sign参数直接就提取所有的评论图了
lyrong2008 发表于 2025-6-21 16:41
ranine 发表于 2025-6-21 17:00
好东西,谢谢分享!
一场荒唐半生梦 发表于 2025-6-21 17:34
楼主有抖店那种吗?
MinaCN 发表于 2025-6-21 17:51
感谢大佬的无私奉献,点赞!感谢大佬的无私奉献,点赞!
2482230 发表于 2025-6-21 18:02
webp格式 用 看图王就能打开,另存一下就好了
qnannan 发表于 2025-6-21 18:15
好东西,谢谢分享!
QAnony 发表于 2025-6-21 19:16
这个具体作什么用处呢
wecanfly9292 发表于 2025-6-21 19:26
淘宝都不装了,用pdd
gaomeng0608 发表于 2025-6-21 19:32
这个可以
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-11-4 05:24

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表