Метод обкатан 31.10.2026 на Авито: сбор выдачи через живой Сафари (do JavaScript), глубокая проверка карточек по чек-листу, OCR фото системным Vision, база проверенных лотов, таблица мёртвых путей обхода антибота. Co-Authored-By: Claude Code <noreply@anthropic.com>
44 lines
2.0 KiB
AppleScript
44 lines
2.0 KiB
AppleScript
-- Сбор выдачи Авито по списку запросов. Вызов: osascript collect.applescript > out.txt
|
|
-- Требует включённой галочки «Разрешить событиям Apple Events выполнять JavaScript» (см. README).
|
|
-- Перед запуском в Сафари должна быть ОТКРЫТА вкладка (любая) — скрипт ходит по ней.
|
|
|
|
on urlenc(s)
|
|
set cmd to "python3 -c \"import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))\" " & quoted form of s
|
|
return do shell script cmd
|
|
end urlenc
|
|
|
|
on searchDump(q)
|
|
tell application "Safari"
|
|
set URL of front document to "https://www.avito.ru/rossiya?q=" & (my urlenc(q)) & "&localPriority=1"
|
|
end tell
|
|
-- ждём появления карточек
|
|
set gotItems to false
|
|
repeat with i from 1 to 25
|
|
delay 0.8
|
|
tell application "Safari"
|
|
try
|
|
set n to (do JavaScript "document.querySelectorAll('a[data-marker=\"item-title\"]').length" in front document) as integer
|
|
on error
|
|
set n to 0
|
|
end try
|
|
end tell
|
|
if n > 0 then
|
|
set gotItems to true
|
|
exit repeat
|
|
end if
|
|
end repeat
|
|
if not gotItems then return "(не загрузилось)"
|
|
tell application "Safari"
|
|
-- заголовок @@ цена @@ ссылка; для локальной выдачи заменить rossiya на /<город>
|
|
return do JavaScript "[...document.querySelectorAll('a[data-marker=\"item-title\"]')].map(a=>{const c=a.closest('[data-marker=\"item\"]'); const p=c?c.querySelector('[data-marker=\"item-price\"]'):null; return (p?p.innerText.replace(/\\s+/g,' ').trim():'?')+' @ '+a.innerText.replace(/\\s+/g,' ').trim()+' @ '+a.href.split('?')[0];}).join('\n')" in front document
|
|
end tell
|
|
end searchDump
|
|
|
|
set queries to {"жесткий диск 3тб", "hdd 3tb", "hdd nas"} -- ← заменить на свои
|
|
|
|
set out to ""
|
|
repeat with q in queries
|
|
set out to out & "### " & q & linefeed & (my searchDump(q)) & linefeed
|
|
end repeat
|
|
return out
|