RedRocket
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Кенко, ты уверен, что это не работает? Я вижу несколько изображений продукта и прокручиваю колесо мыши, чтобы успешно увидеть следующие. Единственная проблема в том, что первое изображение повторяется в позиции 2, насколько я могу судить. Затем вы должны увидеть другие изображения после 2-го. Может быть, я не то сито вставил. Вот опять. Это сделал Клод LOL Код: {"date":"","OfferUp":{"link":"^offerup\\.com/item/detail/([a-f0-9-]+)","res":":\n// Extract unique high-resolution images from OfferUp item pages\nconst doc = new DOMParser().parseFromString($._, \"text/html\");\nconst images = [];\nconst seenFileHashes = new Set(); // Track unique images by their file hash\n\n// Extract all image URLs from the page source using regex\nconst imageRegex = /https:\\/\\/images\\.offerup\\.com\\/([^\"'\\s\\/]+)=\\/(\\d+x\\d+)\\/([a-f0-9]{4})\\/([a-f0-9]{32})\\.(jpg|jpeg|png|webp)/g;\nconst matches = [...$._.matchAll(imageRegex)];\n\n// Group images by their file hash (last part of URL) to identify unique images\nconst imageGroups = new Map();\n\nfor (const match of matches) {\n const [fullUrl, hash, dimensions, folder, filename, ext] = match;\n \n // Skip very small images (likely profile pics or icons)\n if (dimensions === '100x100' || dimensions === '50x50' || dimensions === '64x64') continue;\n \n // Use filename as unique identifier for the image\n const imageId = filename;\n \n if (!imageGroups.has(imageId)) {\n imageGroups.set(imageId, []);\n }\n \n imageGroups.get(imageId).push({\n url: fullUrl,\n hash: hash,\n dimensions: dimensions,\n folder: folder,\n filename: filename,\n ext: ext,\n width: parseInt(dimensions.split('x')[0]),\n height: parseInt(dimensions.split('x')[1])\n });\n}\n\n// For each unique image, pick the best quality version\nfor (const [imageId, variants] of imageGroups) {\n // Sort by total pixels (width * height) to get highest quality\n variants.sort((a, b) => (b.width * b.height) - (a.width * a.height));\n \n // Take the highest quality version that's not square-cropped\n let bestImage = variants[0];\n \n // Prefer non-square images if available (they're usually not cropped)\n for (const variant of variants) {\n if (variant.width !== variant.height && (variant.width * variant.height) >= 400000) {\n bestImage = variant;\n break;\n }\n }\n \n // If we only have square images, pick the largest one\n if (!bestImage || bestImage.width === bestImage.height) {\n // Look for the largest available version, but try common high-res dimensions first\n const preferredDimensions = ['750x1000', '1000x750', '1440x1920', '1512x2016', '2016x1512'];\n \n for (const prefDim of preferredDimensions) {\n const found = variants.find(v => v.dimensions === prefDim);\n if (found) {\n bestImage = found;\n break;\n }\n }\n }\n \n if (bestImage) {\n images.push([bestImage.url, '']);\n }\n}\n\n// If we didn't get any images, try DOM parsing as fallback\nif (images.length === 0) {\n const imgElements = doc.querySelectorAll('img[src*=\"images.offerup.com\"]');\n \n for (const img of imgElements) {\n let src = img.src;\n \n // Skip small images\n if (src.includes('/100x100/') || src.includes('/50x50/') || src.includes('/64x64/')) continue;\n \n // Extract filename to check for duplicates\n const filenameMatch = src.match(/\\/([a-f0-9]{32})\\./); \n if (filenameMatch && !seenFileHashes.has(filenameMatch[1])) {\n seenFileHashes.add(filenameMatch[1]);\n images.push([src, img.alt || '']);\n }\n }\n}\n\nreturn images.length > 0 ? images : null;","img":"^(images\\.offerup\\.com/[^/]+=/)(\\d+x\\d+)/(.+)","to":":\n// Convert OfferUp image thumbnails to high resolution\nconst dimensions = $[2];\nlet newDimensions;\n\n// Map thumbnail sizes to high-res equivalents\nswitch (dimensions) {\n case '250x250':\n case '300x400':\n newDimensions = '1440x1920';\n break;\n case '250x333':\n newDimensions = '1512x2016';\n break;\n default:\n // If already high-res or unknown, keep as is\n return 'https://' + $[1] + dimensions + '/' + $[3];\n}\n\nreturn 'https://' + $[1] + newDimensions + '/' + $[3];","note":"OfferUp image enlarger - works on item detail pages and converts thumbnails to high resolution.\n\nSupported pages:\n- https://offerup.com/item/detail/[item-id]\n- Search results linking to item pages\n\nImage URL patterns:\n- Thumbnail: https://images.offerup.com/HASH=/250x250/path\n- High-res: https://images.offerup.com/HASH=/1440x1920/path\n\nThe sieve will:\n1. Extract all images from item detail pages\n2. Convert thumbnail URLs to high-resolution versions\n3. Return a gallery of all available images for the item"}} |
| Всего записей: 9 | Зарегистр. 28-09-2024 | Отправлено: 00:59 07-06-2025 | Исправлено: RedRocket, 04:58 07-06-2025 |
|