hababr
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору kenko2 Вот починил, подтягиваются отзывы с первой страницы отсортированные по полезности. Код: {"OZON.ru":{"link":"^(ozon\\.ru/(?:product/[\\w-]+|context/detail/id/\\d+))/.*","res":":\ndebugger;\nconst r = []\ntry {\n if (!$[0].includes('/reviews')) {\n const title = (/<title.*?>(.+?)<\\/title>/.exec($._) || [])[1];\n\n // product images\n const regexp = new RegExp('<div data-index=\"\\\\d+\"[\\\\s\\\\S]+?<img loading=\"lazy\" fetchpriority=\"\\\\w+\" src=\"(.+?)\"', 'gi');\n let m;\n while ((m = regexp.exec($._)) !== null) {\n let url = m[1];\n url = url.replace(/\\/\\w+50\\//, '/');\n r.push([url, title]);\n }\n\n // fallback image\n if (!r.length) {\n const url = ($._.match(/<meta.+data-hid=\"name::og:image\" name=\"og:image\" content=\"(.+?)\"/) || [])[1];\n if (url) r.push([url, title]);\n }\n }\n\n // reviews images\n const rUrl = $[0].match(/^(.+?\\/product\\/[\\w-]+)(\\/|$)/)?.[1] + '/reviews/?sort=usefullness_desc';\n const x = new XMLHttpRequest;\n x.open('GET', rUrl, false);\n x.send();\n const data = JSON.parse(x.responseText?.match(/<div id=\"state-webListReviews.+?data-state='(.+?)'/i)[1]);\n\n data.reviews.forEach(f => {\n const c = f.content;\n c.photos.forEach(p => {\n const text = ['⭐' + c.score];\n if (c.comment) text.push(c.comment);\n if (c.positive) text.push('👍🏻 ' + c.positive);\n if (c.negative) text.push('👎🏻 ' + c.negative);\n if (f.createdAt) text.push(new Date(f.createdAt*1000).toISOString().substring(0,10))\n r.push([p.url, text.join(' | ')]);\n });\n });\n} catch (e) {}\nreturn r;","img":"((?:ir|cdn\\d)\\.ozone\\.ru/s3/(?:rp-photo-\\d|multimedia-\\w)/)wc\\d+/(.+\\.jpe?g)","to":"$1$2","note":"Baton34V\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1880#15\nOLD\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=580#11\n\n\n!!!\nВ поисковой выдаче подгружает не только фото товара, но и фото сделанные покупателями + отзывы.\n+\nКурсор рекомендуется наводить на описание товара.\n\nПРИМЕРЫ\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1880#14"}} | Upd: поменял сортировку | Всего записей: 108 | Зарегистр. 21-07-2014 | Отправлено: 14:12 07-08-2023 | Исправлено: hababr, 14:17 07-08-2023 |
|