feat: 插件开发 ozon 端主体完成

This commit is contained in:
Joey
2026-08-16 17:32:43 +08:00
parent 1591d5e35a
commit b57933e983
32 changed files with 1960 additions and 512 deletions
+32 -8
View File
@@ -1,6 +1,10 @@
/**
* 1688 采集配置
* 从 docs/extension/plan.md §6.2 移植(选择器来自 v1.1.8 生产 bundle
* 1688 采集配置DOM 兜底路径)
*
* 新版(2026-08 实测,快照:宝宝平衡车)DOM 大改,锚点从业务类名换成稳定的
* id / data-module 属性;旧选择器保留做兼容(旧版页面仍在线上轮转)。
* 主路径(window.context)见 collector/platforms/1688.ts——DOM 只负责兜底
* 和补充参数表(#productAttributes)与详情图(#detail)。
*/
import type { SiteProfile } from './types';
@@ -12,7 +16,7 @@ export const profile1688: SiteProfile = {
extractItemId: (url) => url.match(/\/offer\/(\d+)\.html/)?.[1] ?? null,
readySelectors: ['.title-content', '#dt-tab', '#screen', '#content'],
readySelectors: ['#productTitle', '.title-content', '#detail', '#dt-tab', '#screen', '#content'],
readyTimeoutMs: 10_000,
// 懒加载真实地址在 data-* 上(顺序不能动)
@@ -23,8 +27,13 @@ export const profile1688: SiteProfile = {
textRules: [
{
kind: 'title',
// 标题被拆成多个 .title-text span,必须 join
selectors: ['.title-content .title-text', '.title-content h1', '.od-pc-offer-title', 'h1'],
selectors: [
'#productTitle .title-content', // 新版:data-module="od_title"
'.title-content .title-text', // 旧版:标题拆多个 span,必须 join
'.title-content h1',
'.od-pc-offer-title',
'h1',
],
extract: 'join',
required: true
},
@@ -33,6 +42,17 @@ export const profile1688: SiteProfile = {
selectors: ['.price-original', '.od-pc-offer-price-priceRange', '.price .value'],
extract: 'first'
},
// 参数表(新版):#productAttributes 是 antd Descriptions 表格,
// th(键)/td(值) 成对平铺在 tr 里——用 cells 模式取兄弟节点
{
kind: 'params',
selectors: [
'#productAttributes th.ant-descriptions-item-label',
'#productAttributes th',
],
extract: 'cells'
},
// 参数表(旧版):行式键值表
{
kind: 'params',
selectors: [
@@ -56,8 +76,11 @@ export const profile1688: SiteProfile = {
key: 'main',
name: '主图',
type: 'img',
// 四套画廊变体(说明 1688 至少有四个线上版本)
selectors: [
// 新版:模块锚点(data-module / module- 类名)
'[data-module="od_picture_gallery"] img',
'.module-od-picture-gallery img',
// 旧版四套画廊变体
'#recyclerview .detail-gallery-turn-wrapper .detail-gallery-img',
'#screen .od-gallery-turn-item-wrapper .od-gallery-img',
'#content .od-scroller-item .v-image-cover',
@@ -79,6 +102,8 @@ export const profile1688: SiteProfile = {
name: 'SKU图片',
type: 'img',
selectors: [
'[data-module="od_sku_selection"] img', // 新版
'.module-od-sku-selection img',
'.pc-sku-wrapper .prop-item-inner-wrapper',
'.sku-item-wrapper',
'.specification-cell',
@@ -86,9 +111,7 @@ export const profile1688: SiteProfile = {
'.expand-view-item',
'.feature-item img'
],
// SKU 缩略图是 CSS 背景图
srcProps: ['backgroundImage'],
// 规格名(五种 DOM 结构)
nameSelectors: ['.prop-name', '.sku-item-name', '.item-label', '.label-name', '.normal-text'],
minWidth: 20,
minHeight: 20
@@ -98,6 +121,7 @@ export const profile1688: SiteProfile = {
name: '详情图',
type: 'img',
selectors: [
'#detail img', // 新版:详情容器(实测 69 张,含少量图标需过滤)
'.de-description-detail img',
'#detailContentContainer img',
'.html-description img'