{"id":469420,"date":"2025-08-03T15:00:18","date_gmt":"2025-08-03T15:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=469420"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=469420","title":{"rendered":"<span>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0410\u0432\u0438\u0442\u043e. \u0414\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430 Python \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 Avito \u0438\u0441\u0447\u0435\u0437\u0430\u044e\u0442 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0437\u0430 \u043c\u0438\u043d\u0443\u0442\u044b. \u0425\u043e\u0442\u0438\u0442\u0435 \u043a\u0443\u043f\u0438\u0442\u044c \u0441\u0442\u0443\u0434\u0438\u044e \u043f\u043e \u0432\u044b\u0433\u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043d\u0435? \u0418\u043b\u0438 \u043d\u0430\u0439\u0442\u0438 iPhone \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0440\u044b\u043d\u043a\u0430? \u041f\u043e\u043a\u0430 \u0432\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u0430\u0439\u0442 \u2014 \u043a\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0441\u044f. \u0410 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 APi \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 Avito \u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0430\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0444\u043e\u043d\u0435, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043a\u043e\u043d \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u0418 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, <strong>\u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e \u0410\u0432\u0438\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0447\u0438\u0441\u043b\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0432\u044b\u0434\u0430\u0432\u0430\u044f 429 \u043e\u0442\u0432\u0435\u0442.<\/strong><\/p>\n<h4>\u0421\u0443\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u041d\u0430\u0448 \u043f\u0430\u0440\u0441\u0435\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a Avito API \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0441\u0441\u044b\u043b\u043e\u043a, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>AVITO_URLS<\/code>. \u041f\u0430\u0440\u0441\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b. \u0411\u043e\u0442 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0435 \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0435\u0439 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>\u0410\u0432\u0438\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c IP \u0430\u0434\u0440\u0435\u0441\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u044f \u0437\u0430\u043f\u0443\u0449\u0443 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 <a href=\"https:\/\/amvera.ru\/\" rel=\"noopener noreferrer nofollow\">Amvera<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0440\u043e\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 (\u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f) IP \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Amvera \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a API Avito \u0431\u0435\u0437 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u043e\u0432\u044b\u0439 IP.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u043a\u0441\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0442\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Amvera<\/h4>\n<p><a href=\"https:\/\/amvera.ru\/?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=avitoparsing\" rel=\"noopener noreferrer nofollow\"><strong>Amvera<\/strong> <\/a>\u2014 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f IT-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u044f. Amvera \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <strong>111 \u0440\u0443\u0431\u043b\u0435\u0439<\/strong> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430.<\/p>\n<h3>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h3>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u043d\u0430\u0448 \u043f\u0430\u0440\u0441\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043d\u0430\u043c\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435: \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0438 \u043a\u0430\u043a \u043c\u044b \u043f\u0430\u0440\u0441\u0438\u043c?<\/p>\n<h4>Avito API<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0439\u0442\u0438 \u0432 \u043b\u044e\u0431\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043d\u0430 \u0430\u0432\u0438\u0442\u043e \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Network \u0432 DevTools \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u0441\u0440\u0435\u0434\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 API, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u2014 \u044d\u0442\u043e <a href=\"https:\/\/www.avito.ru\/web\/1\/main\/items\" rel=\"noopener noreferrer nofollow\"><code>https:\/\/www.avito.ru\/web\/1\/main\/items<\/code><\/a>.<\/p>\n<p>\u0415\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<ul>\n<li>\n<p><code>locationId=637640<\/code> \u2014 \u0440\u0435\u0433\u0438\u043e\u043d (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u041c\u043e\u0441\u043a\u0432\u0430);<\/p>\n<\/li>\n<li>\n<p><code>categoryId=24<\/code> \u2014 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b);<\/p>\n<\/li>\n<li>\n<p><code>sort=date<\/code> \u2014 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0434\u0430\u0442\u0435 (\u0441\u0430\u043c\u044b\u0435 \u043d\u043e\u0432\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435);<\/p>\n<\/li>\n<li>\n<p><code>limit=50<\/code> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u0437\u0430 \u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p><code>page=1<\/code> \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044e);<\/p>\n<\/li>\n<li>\n<p><code>lastStamp=0<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c <code>0<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 JSON \u0441 \u043a\u043b\u044e\u0447\u043e\u043c <code>items<\/code>, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 id, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0446\u0435\u043d\u0443, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 API \u043c\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0430\u0440\u0441\u0435\u0440\u0435.<\/p>\n<h4>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0430\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e ID \u0432 \u0444\u0430\u0439\u043b <code>seen.json<\/code>. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u043d\u0430\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430 Python<\/h3>\n<p>\u041f\u0430\u0440\u0441\u0435\u0440 \u0443 \u043d\u0430\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u2014 \u0442\u0435\u043e\u0440\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435: \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<h4>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<pre><code class=\"python\">import asyncio import aiohttp import os import json from aiogram import Bot, Dispatcher from aiogram.types import InputMediaPhoto from aiogram.exceptions import TelegramBadRequest, TelegramNetworkError from dotenv import load_dotenv <\/code><\/pre>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <code>asyncio<\/code> \u0438 <code>aiohttp<\/code> &#8212; \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, <code>aiogram<\/code> &#8212; \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram Bot API, <code>dotenv<\/code> &#8212; \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">load_dotenv() TOKEN = os.getenv(\"TG_TOKEN\") CHAT_ID = int(os.getenv(\"TG_CHAT_ID\")) AVITO_URLS = os.getenv(\"AVITO_URLS\", \"\").split(\",\") SEEN_FILE = os.getenv(\"SEEN_FILE\", \"\/data\/seen.json\") <\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f: \u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430, ID \u0447\u0430\u0442\u0430, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 API Avito \u0438 \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c id \u0443\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439. \u0417\u0434\u0435\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u2014 \u043f\u0443\u0442\u044c \u043a <code>seen.json<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u043e <code>\/data<\/code> \u2014 \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f <a href=\"https:\/\/docs.amvera.ru\/applications\/storage.html#data\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/a> \u0432 Amvera. \u0415\u0441\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u0441\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0443\u0442.<\/p>\n<pre><code class=\"python\">bot = Bot(token=TOKEN) dp = Dispatcher() <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0431\u043e\u0442\u0430 \u0438 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 (\u0445\u043e\u0442\u044f \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c).<\/p>\n<pre><code class=\"python\">def load_seen_ids():     if os.path.exists(SEEN_FILE):         with open(SEEN_FILE, \"r\") as f:             try:                 return set(json.load(f))             except Exception:                 return set()     return set() <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 id \u0438\u0437 <code>seen.json<\/code>. \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u0442 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"python\">def save_seen_ids(ids):     with open(SEEN_FILE, \"w\") as f:         json.dump(list(ids), f) <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e id \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"python\">async def fetch_avito(session, url):     try:         async with session.get(url.strip()) as response:             if response.status == 200:                 data = await response.json()                 return data.get(\"items\", [])             else:                 print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 {response.status} \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}\")     except Exception as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}: {e}\")     return [] <\/code><\/pre>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API Avito, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<pre><code class=\"python\">async def send_ad(item):     try:         title = item.get(\"title\", \"\u0411\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\")         price = item.get(\"priceDetailed\", {}).get(\"value\", \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\")         url = f\"https:\/\/www.avito.ru{item.get('urlPath', '')}\"         text = f\"\ud83c\udfe0 &lt;b&gt;{title}&lt;\/b&gt;\\n\ud83d\udcb0 \u0426\u0435\u043d\u0430: {price}\\n\ud83d\udd17 &lt;a href=\"\\&amp;quot;{url}\\&amp;quot;\"&gt;\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435&lt;\/a&gt;\"          images = item.get(\"images\", [])         if images:             photo_url = images[0].get(\"864x864\") or images[0].get(\"416x416\")             await bot.send_photo(CHAT_ID, photo_url, caption=text, parse_mode=\"HTML\")         else:             await bot.send_message(CHAT_ID, text, parse_mode=\"HTML\")      except (TelegramBadRequest, TelegramNetworkError) as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: {e}\") <\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0444\u043e\u0442\u043e \u2014 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e.<\/p>\n<pre><code class=\"python\">async def main():     seen_ids = load_seen_ids()      async with aiohttp.ClientSession() as session:         all_items = []         for url in AVITO_URLS:             items = await fetch_avito(session, url)             all_items.extend(items)          new_items = [item for item in all_items if item[\"id\"] not in seen_ids]          for item in sorted(new_items, key=lambda x: x.get(\"sortDate\", 0), reverse=True):             await send_ad(item)             seen_ids.add(item[\"id\"])          save_seen_ids(seen_ids)      await bot.session.close() <\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430: \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0435 id, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441 \u0443\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0434\u0430\u0442\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0445 id.<\/p>\n<pre><code class=\"python\">async def run_forever():     while True:         try:             await main()         except Exception as e:             print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 main: {e}\")         await asyncio.sleep(60) <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 <code>main()<\/code> \u0440\u0430\u0437 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443 &#8212; \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<pre><code class=\"python\">if __name__ == \"__main__\":     asyncio.run(run_forever()) <\/code><\/pre>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434:<\/h3>\n<pre><code class=\"python\">import asyncio import aiohttp import os import json from aiogram import Bot, Dispatcher from aiogram.types import InputMediaPhoto from aiogram.exceptions import TelegramBadRequest, TelegramNetworkError from dotenv import load_dotenv  load_dotenv()  TOKEN = os.getenv(\"TG_TOKEN\") CHAT_ID = int(os.getenv(\"TG_CHAT_ID\")) AVITO_URLS = os.getenv(\"AVITO_URLS\", \"\").split(\",\") SEEN_FILE = os.getenv(\"SEEN_FILE\", \"\/data\/seen.json\")  bot = Bot(token=TOKEN) dp = Dispatcher()  def load_seen_ids():     if os.path.exists(SEEN_FILE):         with open(SEEN_FILE, \"r\") as f:             try:                 return set(json.load(f))             except Exception:                 return set()     return set()  def save_seen_ids(ids):     with open(SEEN_FILE, \"w\") as f:         json.dump(list(ids), f)  async def fetch_avito(session, url):     try:         async with session.get(url.strip()) as response:             if response.status == 200:                 data = await response.json()                 return data.get(\"items\", [])             else:                 print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 {response.status} \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}\")     except Exception as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}: {e}\")     return []  async def send_ad(item):     try:         title = item.get(\"title\", \"\u0411\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\")         price = item.get(\"priceDetailed\", {}).get(\"value\", \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\")         url = f\"https:\/\/www.avito.ru{item.get('urlPath', '')}\"         text = f\"\ud83c\udfe0 &lt;b&gt;{title}&lt;\/b&gt;\\n\ud83d\udcb0 \u0426\u0435\u043d\u0430: {price}\\n\ud83d\udd17 &lt;a href=\"\\&amp;quot;{url}\\&amp;quot;\"&gt;\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435&lt;\/a&gt;\"          images = item.get(\"images\", [])         if images:             photo_url = images[0].get(\"864x864\") or images[0].get(\"416x416\")             await bot.send_photo(CHAT_ID, photo_url, caption=text, parse_mode=\"HTML\")         else:             await bot.send_message(CHAT_ID, text, parse_mode=\"HTML\")      except (TelegramBadRequest, TelegramNetworkError) as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: {e}\")  async def main():     seen_ids = load_seen_ids()      async with aiohttp.ClientSession() as session:         all_items = []         for url in AVITO_URLS:             items = await fetch_avito(session, url)             all_items.extend(items)          new_items = [item for item in all_items if item[\"id\"] not in seen_ids]          for item in sorted(new_items, key=lambda x: x.get(\"sortDate\", 0), reverse=True):             await send_ad(item)             seen_ids.add(item[\"id\"])          save_seen_ids(seen_ids)      await bot.session.close()  async def run_forever():     while True:         try:             await main()         except Exception as e:             print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 main: {e}\")         await asyncio.sleep(60)   if __name__ == \"__main__\":     asyncio.run(run_forever())  <\/code><\/pre>\n<hr\/>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 60 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c.<\/p>\n<h3>\u0414\u0435\u043f\u043b\u043e\u0439<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0434\u0435\u043f\u043b\u043e\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Amvera:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043f\u043e <a href=\"https:\/\/amvera.ru\/?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=avitoparsing\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a> \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c \u043f\u043e\u0447\u0442\u0443. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <strong>111 \u0440\u0443\u0431\u043b\u0435\u0439<\/strong> \u043d\u0430 \u0431\u0430\u043b\u0430\u043d\u0441 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438: <\/p>\n<ol>\n<li>\n<p>\u0422\u0438\u043f \u0441\u0435\u0440\u0432\u0438\u0441\u0430: \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0416\u043c\u0451\u043c \u0434\u0430\u043b\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u0436\u0435\u043b\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0440\u0438\u0444: \u0442\u0430\u0440\u0438\u0444\u0430 &#171;\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u044e\u0441&#187; \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0440\u0441\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u2014 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/code>. \u0422\u0443\u0442 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c 2 \u0444\u0430\u0439\u043b\u0430: <a href=\"http:\/\/parser.py\" rel=\"noopener noreferrer nofollow\"><code>parser.py<\/code><\/a> (\u043a\u043e\u0434 \u0432\u044b\u0448\u0435) \u0438 <code>requirements.txt<\/code> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code>requests==2.32.4 beautifulsoup4==4.13.4 python-dotenv==1.1.1 aiogram==3.21.0 aiohttp python-dateutil<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/code> \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0430\u043a \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d05\/213\/5c4\/d052135c4d047f9c360627444c17ff71.png\" alt=\"\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e\" title=\"\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e\" width=\"1337\" height=\"739\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d05\/213\/5c4\/d052135c4d047f9c360627444c17ff71.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d05\/213\/5c4\/d052135c4d047f9c360627444c17ff71.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0442\u0440\u0438\u0445 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 <code>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/code>.<\/p>\n<p>\u0422\u0430\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c:<\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>PYTHONUNBUFFERED<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <code>1<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u043a\u0440\u0435\u0442 <code>TG_TOKEN<\/code>. \u0412 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432\u0430\u0448 \u0442\u043e\u043a\u0435\u043d.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>TG_CHAT_ID<\/code>. \u0412 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 &#8212; \u0447\u0430\u0442, \u043a\u0443\u0434\u0430 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>AVITO_URLS<\/code> &#8212; \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0435 API URL, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440 \u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0440\u0430\u043d\u0435\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>SEEN_FILE<\/code>  \u0441 \u043f\u0443\u0442\u0435\u043c \u043a seen.json. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 <code>\/data\/seen.json<\/code><\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ee\/2cb\/767\/9ee2cb76707250ce79b0fc63315ecb11.png\" alt=\"\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e\" title=\"\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e\" width=\"1341\" height=\"461\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9ee\/2cb\/767\/9ee2cb76707250ce79b0fc63315ecb11.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ee\/2cb\/767\/9ee2cb76707250ce79b0fc63315ecb11.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0441\u0451 \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 <code>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/code> \u0438 \u0436\u0434\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430!<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8d\/74d\/681\/e8d74d681f3326791d306383c34086b2.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438\" width=\"564\" height=\"978\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e8d\/74d\/681\/e8d74d681f3326791d306383c34086b2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8d\/74d\/681\/e8d74d681f3326791d306383c34086b2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 (\u0434\u043b\u044f \u0431\u043e\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c) \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u0445, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0442\u044c \u0438 \u0434\u043e\u0440\u043e\u0436\u0435, \u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u043d\u0430\u0448 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0410\u0432\u0438\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043e\u0442\u0441\u044b\u043b\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0447\u0430\u0442.<\/p>\n<h3>\u0418\u0442\u043e\u0433 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0410\u0432\u0438\u0442\u043e<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 Avito, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 Avito \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043f\u0440\u044f\u043c\u043e \u0432 \u0447\u0430\u0442. <\/p>\n<p>\u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u044b\u043c. \u0418 \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438: \u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u043c \u0434\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c. <\/p>\n<p>\u0410 \u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432\u044b? \u0418\u043b\u0438, \u043c\u043e\u0436\u0435\u0442, \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u044f \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438? \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0438 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/933510\/\"> https:\/\/habr.com\/ru\/articles\/933510\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 Avito \u0438\u0441\u0447\u0435\u0437\u0430\u044e\u0442 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0437\u0430 \u043c\u0438\u043d\u0443\u0442\u044b. \u0425\u043e\u0442\u0438\u0442\u0435 \u043a\u0443\u043f\u0438\u0442\u044c \u0441\u0442\u0443\u0434\u0438\u044e \u043f\u043e \u0432\u044b\u0433\u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043d\u0435? \u0418\u043b\u0438 \u043d\u0430\u0439\u0442\u0438 iPhone \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0440\u044b\u043d\u043a\u0430? \u041f\u043e\u043a\u0430 \u0432\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u0430\u0439\u0442 \u2014 \u043a\u0442\u043e-\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0441\u044f. \u0410 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 APi \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043d\u043e\u0432\u044b\u043c\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 Avito \u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0430\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0444\u043e\u043d\u0435, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043a\u043e\u043d \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u0418 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, <strong>\u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e \u0410\u0432\u0438\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0447\u0438\u0441\u043b\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0432\u044b\u0434\u0430\u0432\u0430\u044f 429 \u043e\u0442\u0432\u0435\u0442.<\/strong><\/p>\n<h4>\u0421\u0443\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u041d\u0430\u0448 \u043f\u0430\u0440\u0441\u0435\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a Avito API \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0441\u0441\u044b\u043b\u043e\u043a, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>AVITO_URLS<\/code>. \u041f\u0430\u0440\u0441\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b. \u0411\u043e\u0442 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0435 \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0435\u0439 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>\u0410\u0432\u0438\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c IP \u0430\u0434\u0440\u0435\u0441\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u044f \u0437\u0430\u043f\u0443\u0449\u0443 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 <a href=\"https:\/\/amvera.ru\/\" rel=\"noopener noreferrer nofollow\">Amvera<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0440\u043e\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 (\u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f) IP \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Amvera \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a API Avito \u0431\u0435\u0437 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u043e\u0432\u044b\u0439 IP.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u043a\u0441\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0442\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Amvera<\/h4>\n<p><a href=\"https:\/\/amvera.ru\/?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=avitoparsing\" rel=\"noopener noreferrer nofollow\"><strong>Amvera<\/strong> <\/a>\u2014 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f IT-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u044f. Amvera \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <strong>111 \u0440\u0443\u0431\u043b\u0435\u0439<\/strong> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430.<\/p>\n<h3>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h3>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u043d\u0430\u0448 \u043f\u0430\u0440\u0441\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043d\u0430\u043c\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435: \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0438 \u043a\u0430\u043a \u043c\u044b \u043f\u0430\u0440\u0441\u0438\u043c?<\/p>\n<h4>Avito API<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0439\u0442\u0438 \u0432 \u043b\u044e\u0431\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043d\u0430 \u0430\u0432\u0438\u0442\u043e \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Network \u0432 DevTools \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u0441\u0440\u0435\u0434\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 API, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u2014 \u044d\u0442\u043e <a href=\"https:\/\/www.avito.ru\/web\/1\/main\/items\" rel=\"noopener noreferrer nofollow\"><code>https:\/\/www.avito.ru\/web\/1\/main\/items<\/code><\/a>.<\/p>\n<p>\u0415\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<ul>\n<li>\n<p><code>locationId=637640<\/code> \u2014 \u0440\u0435\u0433\u0438\u043e\u043d (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u041c\u043e\u0441\u043a\u0432\u0430);<\/p>\n<\/li>\n<li>\n<p><code>categoryId=24<\/code> \u2014 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b);<\/p>\n<\/li>\n<li>\n<p><code>sort=date<\/code> \u2014 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0434\u0430\u0442\u0435 (\u0441\u0430\u043c\u044b\u0435 \u043d\u043e\u0432\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435);<\/p>\n<\/li>\n<li>\n<p><code>limit=50<\/code> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u0437\u0430 \u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p><code>page=1<\/code> \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044e);<\/p>\n<\/li>\n<li>\n<p><code>lastStamp=0<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c <code>0<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 JSON \u0441 \u043a\u043b\u044e\u0447\u043e\u043c <code>items<\/code>, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 id, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0446\u0435\u043d\u0443, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 API \u043c\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0430\u0440\u0441\u0435\u0440\u0435.<\/p>\n<h4>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0430\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e ID \u0432 \u0444\u0430\u0439\u043b <code>seen.json<\/code>. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u043d\u0430\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430 Python<\/h3>\n<p>\u041f\u0430\u0440\u0441\u0435\u0440 \u0443 \u043d\u0430\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u2014 \u0442\u0435\u043e\u0440\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435: \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<h4>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<pre><code class=\"python\">import asyncio import aiohttp import os import json from aiogram import Bot, Dispatcher from aiogram.types import InputMediaPhoto from aiogram.exceptions import TelegramBadRequest, TelegramNetworkError from dotenv import load_dotenv <\/code><\/pre>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <code>asyncio<\/code> \u0438 <code>aiohttp<\/code> &#8212; \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, <code>aiogram<\/code> &#8212; \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram Bot API, <code>dotenv<\/code> &#8212; \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">load_dotenv() TOKEN = os.getenv(\"TG_TOKEN\") CHAT_ID = int(os.getenv(\"TG_CHAT_ID\")) AVITO_URLS = os.getenv(\"AVITO_URLS\", \"\").split(\",\") SEEN_FILE = os.getenv(\"SEEN_FILE\", \"\/data\/seen.json\") <\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f: \u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430, ID \u0447\u0430\u0442\u0430, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 API Avito \u0438 \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c id \u0443\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439. \u0417\u0434\u0435\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u2014 \u043f\u0443\u0442\u044c \u043a <code>seen.json<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u043e <code>\/data<\/code> \u2014 \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f <a href=\"https:\/\/docs.amvera.ru\/applications\/storage.html#data\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/a> \u0432 Amvera. \u0415\u0441\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u0441\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0443\u0442.<\/p>\n<pre><code class=\"python\">bot = Bot(token=TOKEN) dp = Dispatcher() <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0431\u043e\u0442\u0430 \u0438 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 (\u0445\u043e\u0442\u044f \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c).<\/p>\n<pre><code class=\"python\">def load_seen_ids():     if os.path.exists(SEEN_FILE):         with open(SEEN_FILE, \"r\") as f:             try:                 return set(json.load(f))             except Exception:                 return set()     return set() <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 id \u0438\u0437 <code>seen.json<\/code>. \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u0442 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"python\">def save_seen_ids(ids):     with open(SEEN_FILE, \"w\") as f:         json.dump(list(ids), f) <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e id \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"python\">async def fetch_avito(session, url):     try:         async with session.get(url.strip()) as response:             if response.status == 200:                 data = await response.json()                 return data.get(\"items\", [])             else:                 print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 {response.status} \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}\")     except Exception as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}: {e}\")     return [] <\/code><\/pre>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API Avito, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<pre><code class=\"python\">async def send_ad(item):     try:         title = item.get(\"title\", \"\u0411\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\")         price = item.get(\"priceDetailed\", {}).get(\"value\", \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\")         url = f\"https:\/\/www.avito.ru{item.get('urlPath', '')}\"         text = f\"\ud83c\udfe0 &lt;b&gt;{title}&lt;\/b&gt;\\n\ud83d\udcb0 \u0426\u0435\u043d\u0430: {price}\\n\ud83d\udd17 &lt;a href=\"\\&amp;quot;{url}\\&amp;quot;\"&gt;\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435&lt;\/a&gt;\"          images = item.get(\"images\", [])         if images:             photo_url = images[0].get(\"864x864\") or images[0].get(\"416x416\")             await bot.send_photo(CHAT_ID, photo_url, caption=text, parse_mode=\"HTML\")         else:             await bot.send_message(CHAT_ID, text, parse_mode=\"HTML\")      except (TelegramBadRequest, TelegramNetworkError) as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: {e}\") <\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0444\u043e\u0442\u043e \u2014 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e.<\/p>\n<pre><code class=\"python\">async def main():     seen_ids = load_seen_ids()      async with aiohttp.ClientSession() as session:         all_items = []         for url in AVITO_URLS:             items = await fetch_avito(session, url)             all_items.extend(items)          new_items = [item for item in all_items if item[\"id\"] not in seen_ids]          for item in sorted(new_items, key=lambda x: x.get(\"sortDate\", 0), reverse=True):             await send_ad(item)             seen_ids.add(item[\"id\"])          save_seen_ids(seen_ids)      await bot.session.close() <\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430: \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0435 id, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441 \u0443\u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0434\u0430\u0442\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0445 id.<\/p>\n<pre><code class=\"python\">async def run_forever():     while True:         try:             await main()         except Exception as e:             print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 main: {e}\")         await asyncio.sleep(60) <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 <code>main()<\/code> \u0440\u0430\u0437 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443 &#8212; \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<pre><code class=\"python\">if __name__ == \"__main__\":     asyncio.run(run_forever()) <\/code><\/pre>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434:<\/h3>\n<pre><code class=\"python\">import asyncio import aiohttp import os import json from aiogram import Bot, Dispatcher from aiogram.types import InputMediaPhoto from aiogram.exceptions import TelegramBadRequest, TelegramNetworkError from dotenv import load_dotenv  load_dotenv()  TOKEN = os.getenv(\"TG_TOKEN\") CHAT_ID = int(os.getenv(\"TG_CHAT_ID\")) AVITO_URLS = os.getenv(\"AVITO_URLS\", \"\").split(\",\") SEEN_FILE = os.getenv(\"SEEN_FILE\", \"\/data\/seen.json\")  bot = Bot(token=TOKEN) dp = Dispatcher()  def load_seen_ids():     if os.path.exists(SEEN_FILE):         with open(SEEN_FILE, \"r\") as f:             try:                 return set(json.load(f))             except Exception:                 return set()     return set()  def save_seen_ids(ids):     with open(SEEN_FILE, \"w\") as f:         json.dump(list(ids), f)  async def fetch_avito(session, url):     try:         async with session.get(url.strip()) as response:             if response.status == 200:                 data = await response.json()                 return data.get(\"items\", [])             else:                 print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 {response.status} \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}\")     except Exception as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 {url}: {e}\")     return []  async def send_ad(item):     try:         title = item.get(\"title\", \"\u0411\u0435\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\")         price = item.get(\"priceDetailed\", {}).get(\"value\", \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\")         url = f\"https:\/\/www.avito.ru{item.get('urlPath', '')}\"         text = f\"\ud83c\udfe0 &lt;b&gt;{title}&lt;\/b&gt;\\n\ud83d\udcb0 \u0426\u0435\u043d\u0430: {price}\\n\ud83d\udd17 &lt;a href=\"\\&amp;quot;{url}\\&amp;quot;\"&gt;\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435&lt;\/a&gt;\"          images = item.get(\"images\", [])         if images:             photo_url = images[0].get(\"864x864\") or images[0].get(\"416x416\")             await bot.send_photo(CHAT_ID, photo_url, caption=text, parse_mode=\"HTML\")         else:             await bot.send_message(CHAT_ID, text, parse_mode=\"HTML\")      except (TelegramBadRequest, TelegramNetworkError) as e:         print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c: {e}\")  async def main():     seen_ids = load_seen_ids()      async with aiohttp.ClientSession() as session:         all_items = []         for url in AVITO_URLS:             items = await fetch_avito(session, url)             all_items.extend(items)          new_items = [item for item in all_items if item[\"id\"] not in seen_ids]          for item in sorted(new_items, key=lambda x: x.get(\"sortDate\", 0), reverse=True):             await send_ad(item)             seen_ids.add(item[\"id\"])          save_seen_ids(seen_ids)      await bot.session.close()  async def run_forever():     while True:         try:             await main()         except Exception as e:             print(f\"[!] \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 main: {e}\")         await asyncio.sleep(60)   if __name__ == \"__main__\":     asyncio.run(run_forever())  <\/code><\/pre>\n<hr\/>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 60 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c.<\/p>\n<h3>\u0414\u0435\u043f\u043b\u043e\u0439<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-469420","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=469420"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469420\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=469420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=469420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=469420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}