{"id":378295,"date":"2024-06-07T15:01:05","date_gmt":"2024-06-07T15:01:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378295"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378295","title":{"rendered":"<span>\u041d\u043e\u0432\u044b\u0439 Selenium Python: \u0441\u0442\u0435\u043b\u0441-\u0440\u0435\u0436\u0438\u043c, \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u0441\u043a\u0440\u044b\u0442\u0430\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/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>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u0423 \u043c\u0435\u043d\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438: \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 Selenium \u0441\u0442\u0430\u043b\u0430 \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;!<\/p>\n<p>\u0412 \u0447\u0435\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043b\u0438\u043a\u0431\u0435\u0437<\/h3>\n<p><strong>Selenium<\/strong> \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Python, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>Selenium \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 (\u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043a\u043b\u0438\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c<\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b:<\/h4>\n<ul>\n<li>\n<p><strong>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e<\/strong>: \u041b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0447\u0435\u0440\u0435\u0437 CSS, ID, \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u0435\u0433\u0438 \u0438 XPath.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430<\/strong>: \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e 2-3 \u0447\u0430\u0441\u043e\u0432 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Selenium.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041c\u0438\u043d\u0443\u0441\u044b:<\/h4>\n<ul>\n<li>\n<p><strong>\u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u044f\u0436\u0435\u043b\u044b\u0439 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/strong> (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432)<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u043c<\/h3>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Selenium \u0438 \u0440\u044f\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0435\u043b\u0441-\u0440\u0435\u0436\u0438\u043c\u0435 \u0438 \u0431\u0435\u0437 \u043f\u043b\u0430\u0448\u043a\u0438 \u00ab\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e\u00bb.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043b\u0438\u0447\u043d\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 (\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u0432\u043e\u0434\u0430 \u0438 \u0442.\u0434.).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 User-Agent \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c\u0438 \u0432 \u0441\u0435\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u0438 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043a\u0440\u044b\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h3>\n<pre><code class=\"powershell\">pip install selenium selenium-stealth fake-useragent<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>requirements.txt<\/code> (\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u043d\u0438\u0436\u0435).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/017\/8f1\/4e5\/0178f14e50e5b325b5e2b4fd1f6736ad.jpg\" alt=\"pip install -r .\\req.txt \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Pycharm\" title=\"pip install -r .\\req.txt \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Pycharm\" width=\"908\" height=\"384\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/017\/8f1\/4e5\/0178f14e50e5b325b5e2b4fd1f6736ad.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>pip install -r .\\req.txt \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Pycharm<\/figcaption><\/div>\n<\/figure>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/h4>\n<pre><code class=\"python\">import os from fake_useragent import UserAgent from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium_stealth import stealth import time<\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0433\u043e User-Agent:<\/h4>\n<pre><code class=\"python\">def get_random_chrome_user_agent():     user_agent = UserAgent(browsers='chrome', os='windows', platforms='pc')     return user_agent.random<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 User-Agent \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 Chrome \u043f\u043e\u0434 Windows.<\/p>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/h4>\n<p><strong>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 users \u0432 \u043a\u043e\u0440\u043d\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430!<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0418\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u044e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043f\u043e\u0434 \u0441\u0435\u043b\u0435\u043d\u0438\u0443\u043c) \u044f \u043f\u0440\u0438\u0432\u044b\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00ab\u043a\u0430\u043a \u0435\u0441\u0442\u044c\u00bb, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u044e \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">def create_driver(user_id=1):     options = Options()     options.add_argument(\"start-maximized\")     options.add_experimental_option(\"excludeSwitches\", [\"enable-automation\"])     options.add_experimental_option('useAutomationExtension', False)      script_dir = os.path.dirname(os.path.abspath(__file__))     base_directory = os.path.join(script_dir, 'users')     user_directory = os.path.join(base_directory, f'user_{user_id}')      options.add_argument(f'user-data-dir={user_directory}')     options.add_argument('--disable-gpu')     options.add_argument('--disable-dev-shm-usage')     options.add_argument(\"--disable-notifications\")     options.add_argument(\"--disable-popup-blocking\")     options.add_argument('--no-sandbox')     # options.add_argument('--headless')      driver = webdriver.Chrome(options=options)     ua = get_random_chrome_user_agent()     stealth(driver=driver,             user_agent=ua,             languages=[\"ru-RU\", \"ru\"],             vendor=\"Google Inc.\",             platform=\"Win32\",             webgl_vendor=\"Intel Inc.\",             renderer=\"Intel Iris OpenGL Engine\",             fix_hairline=True,             run_on_insecure_origins=True             )      driver.execute_cdp_cmd(\"Page.addScriptToEvaluateOnNewDocument\", {         'source': '''             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;       '''     })     return driver <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0442\u043e\u0432. \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u041e\u043d, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u043e\u043b\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<p> &#8212; \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c<\/p>\n<p>&#8212; \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<p>&#8212; \u043a\u043b\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u044f\u0441\u043d\u044e.<\/p>\n<p>\u0412\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435, \u043f\u043e\u0442\u043e\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u043b\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440. \u0412\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c, \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u044d\u0448 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Selenium (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435).<\/p>\n<pre><code class=\"python\">options = Options()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Options<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f Chrome WebDriver.<\/p>\n<pre><code class=\"python\">options.add_argument(\"start-maximized\")<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430.<\/p>\n<pre><code class=\"python\">options.add_experimental_option(\"excludeSwitches\", [\"enable-automation\"])<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c &#171;enable-automation&#187;, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f WebDriver.<\/p>\n<pre><code class=\"python\">options.add_experimental_option('useAutomationExtension', False)<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 WebDriver.<\/p>\n<pre><code class=\"python\">script_dir = os.path.dirname(os.path.abspath(__file__))<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f. <strong>file<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0443\u0442\u044c \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0444\u0430\u0439\u043b\u0443.<\/p>\n<pre><code class=\"python\">base_directory = os.path.join(script_dir, 'users')<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>users<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0447\u0442\u043e \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. (\u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f &#8212; \u0438\u0441\u043f\u0440\u0430\u0432\u044c\u0442\u0435). \u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u043f\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u00ab\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c\u00bb.<\/p>\n<pre><code class=\"python\">user_directory = os.path.join(base_directory, f'user_{user_id}')<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>user_id<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 <code>user_id<\/code> \u0440\u0430\u0432\u043d\u043e <code>1<\/code>, \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0443\u0442\u044c <code>users\/user_1<\/code>.<\/p>\n<pre><code class=\"python\">options.add_argument(f'user-data-dir={user_directory}')<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f Chrome, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438 Chrome \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014disable-gpu')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GPU \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u042d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0441\u0440\u0435\u0434\u0430\u0445 \u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441 \u043d\u0438\u043c \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">options.add_argument('--disable-dev-shm-usage')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 <code>\/dev\/shm<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445.<\/p>\n<pre><code class=\"python\">options.add_argument(\"\u2014disable-notifications\")<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<pre><code class=\"python\">options.add_argument(\"\u2014disable-popup-blocking\")<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u043a\u043e\u043d.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014no-sandbox')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430 (sandbox) \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445, \u043d\u043e \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u0441\u0440\u0435\u0434\u0430\u0445 \u0431\u0435\u0437 GUI, \u043d\u043e \u0442\u043e\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014headless')<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0432 \u0431\u0435\u0437\u0433\u043e\u043b\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (\u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0444\u043e\u043d\u043e\u043c), \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u044d\u0442\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0431\u044b\u0432\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0448\u0442\u0443\u043a\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043c\u043d\u043e\u0433\u0434\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u0432\u043e\u0432\u0441\u0435 \u0441\u0430\u0439\u0442 \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u0440\u0443\u0437\u0435\u0440\u0443. \u0422\u0430\u043a \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0431\u0443\u0434\u044c\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d.<\/p>\n<pre><code class=\"python\">driver = webdriver.Chrome(options=options)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 WebDriver \u0434\u043b\u044f Chrome \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 <code>options<\/code>.<\/p>\n<pre><code class=\"python\">ua = get_random_chrome_user_agent()<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 user-agent \u0434\u043b\u044f Chrome. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435 \u0438\u043b\u0438 \u0432\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 user-agent.<\/p>\n<pre><code class=\"python\">stealth(driver=driver,             user_agent=ua,             languages=[\"ru-RU\", \"ru\"],             vendor=\"Google Inc.\",             platform=\"Win32\",             webgl_vendor=\"Intel Inc.\",             renderer=\"Intel Iris OpenGL Engine\",             fix_hairline=True,             run_on_insecure_origins=True             )<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>stealth<\/code> \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebDriver. \u0417\u0434\u0435\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>user_agent<\/code>, <code>languages<\/code>, <code>vendor<\/code>, <code>platform<\/code>, <code>webgl_vendor<\/code>, <code>renderer<\/code>, \u0438 \u0434\u0440\u0443\u0433\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0435\u043c\u044b\u043c \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 WebDriver.<\/p>\n<pre><code class=\"python\">driver.execute_cdp_cmd(\"Page.addScriptToEvaluateOnNewDocument\", {         'source': '''             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;       '''     })<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 CDP (Chrome DevTools Protocol) \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 window, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f WebDriver. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u041e\u0437\u043e\u043d \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430  window.<\/p>\n<pre><code class=\"python\">return driver<\/code><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 WebDriver.<\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443? \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u0441\u0430\u0439\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0437\u0430\u043a\u0440\u043e\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0430\u0439\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u043c\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\">def main_login(user_id=1):     driver = create_driver(user_id)     driver.get('Cc\u044b\u043b\u043a\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0441\u0430\u0439\u0442)     time.sleep(350)<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e \u0442\u0443\u0442 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u0443\u0437\u0443 \u0432 350 \u0441\u0435\u043a\u0443\u043d\u0434 \u0447\u0442\u043e\u0431 \u044f \u0443\u0441\u043f\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u043e\u0439 \u043a \u0444\u043e\u0440\u043c\u0435, \u043a\u043d\u043e\u043f\u043a\u0430\u043c, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/98a\/d04\/5f7\/98ad045f79f0db73000d7cf1716d2e66.png\" alt=\"\u0418 \u0442\u0430\u043a. \u042f \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0430\u0439\u0442. \u0412\u0438\u0434\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0447\u0442\u043e \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e \u043d\u0435\u0442. \u041a\u0430\u043a \u0438 \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c\" title=\"\u0418 \u0442\u0430\u043a. \u042f \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0430\u0439\u0442. \u0412\u0438\u0434\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0447\u0442\u043e \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e \u043d\u0435\u0442. \u041a\u0430\u043a \u0438 \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c\" width=\"1261\" height=\"225\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98a\/d04\/5f7\/98ad045f79f0db73000d7cf1716d2e66.png\"\/><\/p>\n<div><figcaption>\u0418 \u0442\u0430\u043a. \u042f \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0430\u0439\u0442. \u0412\u0438\u0434\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0447\u0442\u043e \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e \u043d\u0435\u0442. \u041a\u0430\u043a \u0438 \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0435\u043b\u0430\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0443\u043a\u0430\u043c\u0438<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b2c\/80a\/169\/b2c80a169efe17c5ce7d70da78eefc91.png\" alt=\"\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0432\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439.\" title=\"\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0432\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439.\" width=\"1287\" height=\"298\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b2c\/80a\/169\/b2c80a169efe17c5ce7d70da78eefc91.png\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0432\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439.<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 user_id \u2014 1.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/496\/8c8\/8b6\/4968c88b68477ba8f21cc0502d07b1f0.jpg\" alt=\"\u041c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a\" title=\"\u041c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a\" width=\"461\" height=\"773\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/496\/8c8\/8b6\/4968c88b68477ba8f21cc0502d07b1f0.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0430\u043f\u043e\u043a \u0438 \u0444\u0430\u0439\u043b\u043e\u0432. \u041f\u043e\u0445\u043e\u0436\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u043f\u0430\u043f\u043a\u0430\u0445 \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u0422\u0430\u043a \u0440\u0430\u0431\u043e\u0430\u0435\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u0422\u044f\u0436\u0435\u043b\u043e\u0432\u0430\u0442 \u043e\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0439\u0442\u0438 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044c. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a 1 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 (\u043f\u0435\u0440\u0435\u0434 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439) \u0438 \u043e\u043d \u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/edc\/d27\/b35\/edcd27b35d9c7ed0f417c6f7590ba323.png\" alt=\"\u0412\u0441\u0435 \u043e\u043a\" title=\"\u0412\u0441\u0435 \u043e\u043a\" width=\"1238\" height=\"286\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edc\/d27\/b35\/edcd27b35d9c7ed0f417c6f7590ba323.png\"\/><\/p>\n<div><figcaption>\u0412\u0441\u0435 \u043e\u043a<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e. \u041c\u044b \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435 \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u00ab\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u041f\u041e\u00bb.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0444\u0438\u0448\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0441\u0435\u043b\u0435\u043d\u0438\u0443\u043c\u043e\u043c \u2014 \u043f\u0438\u0448\u0438\u0442\u0435. \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439.<\/p>\n<p>\u041a\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u2014 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a\u0438. \u0412\u0430\u0448\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430.<\/p>\n<p>\u0414\u043e \u0441\u043a\u043e\u0440\u043e\u0433\u043e!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/820213\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0423\u0437\u043d\u0430\u043b\u0438 \u043d\u043e\u0432\u043e\u0435?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">76.47% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u0430<\/span><span class=\"tm-article-poll__answer-votes\">13<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 76.47%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">23.53% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442<\/span><span class=\"tm-article-poll__answer-votes\">4<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 23.53%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 17 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \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\/820213\/\"> https:\/\/habr.com\/ru\/articles\/820213\/<\/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>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u0423 \u043c\u0435\u043d\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438: \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 Selenium \u0441\u0442\u0430\u043b\u0430 \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;!<\/p>\n<p>\u0412 \u0447\u0435\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043b\u0438\u043a\u0431\u0435\u0437<\/h3>\n<p><strong>Selenium<\/strong> \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Python, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>Selenium \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 (\u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043a\u043b\u0438\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c<\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b:<\/h4>\n<ul>\n<li>\n<p><strong>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e<\/strong>: \u041b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0447\u0435\u0440\u0435\u0437 CSS, ID, \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u0435\u0433\u0438 \u0438 XPath.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430<\/strong>: \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e 2-3 \u0447\u0430\u0441\u043e\u0432 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Selenium.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041c\u0438\u043d\u0443\u0441\u044b:<\/h4>\n<ul>\n<li>\n<p><strong>\u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u044f\u0436\u0435\u043b\u044b\u0439 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/strong> (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432)<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u043c<\/h3>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Selenium \u0438 \u0440\u044f\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0435\u043b\u0441-\u0440\u0435\u0436\u0438\u043c\u0435 \u0438 \u0431\u0435\u0437 \u043f\u043b\u0430\u0448\u043a\u0438 \u00ab\u0411\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e\u00bb.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043b\u0438\u0447\u043d\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 (\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u0432\u043e\u0434\u0430 \u0438 \u0442.\u0434.).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 User-Agent \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c\u0438 \u0432 \u0441\u0435\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u0438 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043a\u0440\u044b\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h3>\n<pre><code class=\"powershell\">pip install selenium selenium-stealth fake-useragent<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>requirements.txt<\/code> (\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u043d\u0438\u0436\u0435).<\/p>\n<figure class=\"full-width\">\n<div><figcaption>pip install -r .\\req.txt \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Pycharm<\/figcaption><\/div>\n<\/figure>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/h4>\n<pre><code class=\"python\">import os from fake_useragent import UserAgent from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium_stealth import stealth import time<\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0433\u043e User-Agent:<\/h4>\n<pre><code class=\"python\">def get_random_chrome_user_agent():     user_agent = UserAgent(browsers='chrome', os='windows', platforms='pc')     return user_agent.random<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 User-Agent \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 Chrome \u043f\u043e\u0434 Windows.<\/p>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/h4>\n<p><strong>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 users \u0432 \u043a\u043e\u0440\u043d\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430!<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0418\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u044e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043f\u043e\u0434 \u0441\u0435\u043b\u0435\u043d\u0438\u0443\u043c) \u044f \u043f\u0440\u0438\u0432\u044b\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00ab\u043a\u0430\u043a \u0435\u0441\u0442\u044c\u00bb, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u044e \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">def create_driver(user_id=1):     options = Options()     options.add_argument(\"start-maximized\")     options.add_experimental_option(\"excludeSwitches\", [\"enable-automation\"])     options.add_experimental_option('useAutomationExtension', False)      script_dir = os.path.dirname(os.path.abspath(__file__))     base_directory = os.path.join(script_dir, 'users')     user_directory = os.path.join(base_directory, f'user_{user_id}')      options.add_argument(f'user-data-dir={user_directory}')     options.add_argument('--disable-gpu')     options.add_argument('--disable-dev-shm-usage')     options.add_argument(\"--disable-notifications\")     options.add_argument(\"--disable-popup-blocking\")     options.add_argument('--no-sandbox')     # options.add_argument('--headless')      driver = webdriver.Chrome(options=options)     ua = get_random_chrome_user_agent()     stealth(driver=driver,             user_agent=ua,             languages=[\"ru-RU\", \"ru\"],             vendor=\"Google Inc.\",             platform=\"Win32\",             webgl_vendor=\"Intel Inc.\",             renderer=\"Intel Iris OpenGL Engine\",             fix_hairline=True,             run_on_insecure_origins=True             )      driver.execute_cdp_cmd(\"Page.addScriptToEvaluateOnNewDocument\", {         'source': '''             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;       '''     })     return driver <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0442\u043e\u0432. \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u041e\u043d, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u043e\u043b\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<p> &#8212; \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c<\/p>\n<p>&#8212; \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<p>&#8212; \u043a\u043b\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u044f\u0441\u043d\u044e.<\/p>\n<p>\u0412\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435, \u043f\u043e\u0442\u043e\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u043b\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440. \u0412\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c, \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u044d\u0448 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Selenium (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435).<\/p>\n<pre><code class=\"python\">options = Options()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Options<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f Chrome WebDriver.<\/p>\n<pre><code class=\"python\">options.add_argument(\"start-maximized\")<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430.<\/p>\n<pre><code class=\"python\">options.add_experimental_option(\"excludeSwitches\", [\"enable-automation\"])<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c &#171;enable-automation&#187;, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f WebDriver.<\/p>\n<pre><code class=\"python\">options.add_experimental_option('useAutomationExtension', False)<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 WebDriver.<\/p>\n<pre><code class=\"python\">script_dir = os.path.dirname(os.path.abspath(__file__))<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f. <strong>file<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0443\u0442\u044c \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0444\u0430\u0439\u043b\u0443.<\/p>\n<pre><code class=\"python\">base_directory = os.path.join(script_dir, 'users')<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>users<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0447\u0442\u043e \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. (\u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f &#8212; \u0438\u0441\u043f\u0440\u0430\u0432\u044c\u0442\u0435). \u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u043f\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u00ab\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c\u00bb.<\/p>\n<pre><code class=\"python\">user_directory = os.path.join(base_directory, f'user_{user_id}')<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>user_id<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 <code>user_id<\/code> \u0440\u0430\u0432\u043d\u043e <code>1<\/code>, \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0443\u0442\u044c <code>users\/user_1<\/code>.<\/p>\n<pre><code class=\"python\">options.add_argument(f'user-data-dir={user_directory}')<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f Chrome, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438 Chrome \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014disable-gpu')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GPU \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u042d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0441\u0440\u0435\u0434\u0430\u0445 \u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441 \u043d\u0438\u043c \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">options.add_argument('--disable-dev-shm-usage')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 <code>\/dev\/shm<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445.<\/p>\n<pre><code class=\"python\">options.add_argument(\"\u2014disable-notifications\")<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<pre><code class=\"python\">options.add_argument(\"\u2014disable-popup-blocking\")<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u043a\u043e\u043d.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014no-sandbox')<\/code><\/pre>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430 (sandbox) \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445, \u043d\u043e \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u0441\u0440\u0435\u0434\u0430\u0445 \u0431\u0435\u0437 GUI, \u043d\u043e \u0442\u043e\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"python\">options.add_argument('\u2014headless')<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0432 \u0431\u0435\u0437\u0433\u043e\u043b\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (\u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0444\u043e\u043d\u043e\u043c), \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u044d\u0442\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0431\u044b\u0432\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0448\u0442\u0443\u043a\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043c\u043d\u043e\u0433\u0434\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u0432\u043e\u0432\u0441\u0435 \u0441\u0430\u0439\u0442 \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u0440\u0443\u0437\u0435\u0440\u0443. \u0422\u0430\u043a \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0431\u0443\u0434\u044c\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d.<\/p>\n<pre><code class=\"python\">driver = webdriver.Chrome(options=options)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 WebDriver \u0434\u043b\u044f Chrome \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 <code>options<\/code>.<\/p>\n<pre><code class=\"python\">ua = get_random_chrome_user_agent()<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 user-agent \u0434\u043b\u044f Chrome. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435 \u0438\u043b\u0438 \u0432\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 user-agent.<\/p>\n<pre><code class=\"python\">stealth(driver=driver,             user_agent=ua,             languages=[\"ru-RU\", \"ru\"],             vendor=\"Google Inc.\",             platform=\"Win32\",             webgl_vendor=\"Intel Inc.\",             renderer=\"Intel Iris OpenGL Engine\",             fix_hairline=True,             run_on_insecure_origins=True             )<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>stealth<\/code> \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebDriver. \u0417\u0434\u0435\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>user_agent<\/code>, <code>languages<\/code>, <code>vendor<\/code>, <code>platform<\/code>, <code>webgl_vendor<\/code>, <code>renderer<\/code>, \u0438 \u0434\u0440\u0443\u0433\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0435\u043c\u044b\u043c \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 WebDriver.<\/p>\n<pre><code class=\"python\">driver.execute_cdp_cmd(\"Page.addScriptToEvaluateOnNewDocument\", {         'source': '''             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;             delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;       '''     })<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 CDP (Chrome DevTools Protocol) \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 window, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f WebDriver. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u041e\u0437\u043e\u043d \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430  window.<\/p>\n<pre><code class=\"python\">return driver<\/code><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 WebDriver.<\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443? \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u0441\u0430\u0439\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0437\u0430\u043a\u0440\u043e\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0430\u0439\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431\u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u043c\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\">def main_login(user_id=1):     driver = create_driver(user_id)     driver.get('Cc\u044b\u043b\u043a\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0441\u0430\u0439\u0442)     time.sleep(350)<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e \u0442\u0443\u0442 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u0443\u0437\u0443 \u0432 350 \u0441\u0435\u043a\u0443\u043d\u0434 \u0447\u0442\u043e\u0431 \u044f \u0443\u0441\u043f\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u043e\u0439 \u043a \u0444\u043e\u0440\u043c\u0435, \u043a\u043d\u043e\u043f\u043a\u0430\u043c, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\">\n<div><figcaption>\u0418 \u0442\u0430\u043a. \u042f \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0430\u0439\u0442. \u0412\u0438\u0434\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0447\u0442\u043e \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u041f\u041e \u043d\u0435\u0442. \u041a\u0430\u043a \u0438 \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0430\u0439\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0435\u043b\u0430\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0443\u043a\u0430\u043c\u0438<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0432\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439.<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 user_id \u2014 1.<\/p>\n<figure class=\"\">\n<div><figcaption>\u041c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0430\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-378295","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378295","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=378295"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378295\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}