{"id":471948,"date":"2025-08-24T09:00:25","date_gmt":"2025-08-24T09:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=471948"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=471948","title":{"rendered":"<span>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python: \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0434\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432<\/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<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python. \u041c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0443 HTML \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 BeautifulSoup, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 pandas \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043f \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0441 IMDb) \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 CSV-\u0444\u0430\u0439\u043b.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c \u043d\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <code>beautifulsoup4<\/code> <code>requests<\/code> <code>pandas<\/code> \u043d\u0430 python \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c python (\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u0441\u0438\u0438 3&gt; \u043d\u043e \u043c\u043d\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a\u0430\u044f \u0443 \u0432\u0430\u0441 \u0432\u0435\u0440\u0441\u0438\u044f).<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip: <code>pip install beautifulsoup4 requests pandas<\/code><\/p>\n<h3>1. \u041f\u0430\u0440\u0441\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/h3>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (regex) \u2014 \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c. \u0412 Python \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c re.<\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 email-\u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u0435\u0440\u0432\u044b\u0439 email.<\/p>\n<pre><code class=\"python\">import re  text = \"\u041c\u043e\u0438 emails: example@mail.com \u0438 test@domain.ru\" pattern = r\"\\b[A-Za-z0-9.\\_%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b\"  emails = re.findall(pattern, text)  print(emails[0]) # \u0412\u044b\u0432\u043e\u0434: example@mail.com <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0449\u0435\u0442 \u0442\u0438\u043f\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 email: \u0438\u043c\u044f@\u0434\u043e\u043c\u0435\u043d.\u0442\u043e\u0447\u043a\u0430.\u0434\u043e\u043c\u0435\u043d.<\/p>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0434\u0430\u0442\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0414\u0414.\u041c\u041c.\u0413\u0413\u0413\u0413 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e (\u0434\u0435\u043d\u044c \u043e\u0442 01 \u0434\u043e 31, \u043c\u0435\u0441\u044f\u0446 \u043e\u0442 01 \u0434\u043e 12).<\/p>\n<pre><code class=\"python\">import re  text = \"\u0414\u0430\u0442\u044b: 15.08.2023, 32.13.2024 (\u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f), 01.01.2025\" pattern = r\"\\b(0[1-9]|[12][0-9]|3[01])\\.(0[1-9]|1[0-2])\\.(20[0-9]{2})\\b\"  dates = re.findall(pattern, text)  print(dates) # \u0412\u044b\u0432\u043e\u0434: [('15', '08', '2023'), ('01', '01', '2025')] <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0434\u043b\u044f \u0434\u043d\u0435\u0439 \u0438 \u043c\u0435\u0441\u044f\u0446\u0435\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0434\u0430\u0442.<\/p>\n<h3>2. \u041f\u0430\u0440\u0441\u0438\u043c HTML (\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 BeautifulSoup)<\/h3>\n<p>BeautifulSoup \u2014 \u044d\u0442\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 HTML \u0438 XML \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0432\u0438\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0438\u0441\u043a\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0442\u0435\u0433\u0430\u043c, \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c. \u041a\u0440\u0430\u0442\u043a\u043e: \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 pip install beautifulsoup4, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u0440\u0441\u0435\u0440\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 &#8216;html.parser&#8217; \u0438\u043b\u0438 &#8216;lxml&#8217;.<\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e HTML.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  html = \"\"\" &lt;html&gt;  &lt;head&gt;&lt;title&gt;\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b&lt;\/title&gt;&lt;\/head&gt;  &lt;body&gt;&lt;h1&gt;\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a&lt;\/h1&gt;&lt;\/body&gt; &lt;\/html&gt; \"\"\"  soup = BeautifulSoup(html, \"html.parser\") title = soup.find(\"title\").text  print(title) # \u0412\u044b\u0432\u043e\u0434: \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 Soup \u0438 \u0438\u0449\u0435\u043c \u0442\u0435\u0433 title.<\/p>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0437 HTML \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c &#8216;link&#8217;.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  html = \"\"\" &lt;html&gt;   &lt;head&gt;&lt;title&gt;\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b&lt;\/title&gt;&lt;\/head&gt;   &lt;body&gt;&lt;h1&gt;\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a&lt;\/h1&gt;&lt;\/body&gt; &lt;\/html&gt; \"\"\"  soup = BeautifulSoup(html, \"html.parser\") title = soup.find(\"title\").text  print(title)  # \u0412\u044b\u0432\u043e\u0434: \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <\/code><\/pre>\n<p>\u041c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 href.<\/p>\n<h3>3. \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 pandas<\/h3>\n<p>Pandas \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 Python. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u043e\u0434\u0435 DataFrame (\u0442\u0430\u0431\u043b\u0438\u0446\u044b) \u0438 Series (\u0441\u0442\u043e\u043b\u0431\u0446\u044b), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 (CSV, Excel \u0438 \u0442.\u0434.), \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p><strong>DataFrame<\/strong>: \u0414\u0432\u0443\u043c\u0435\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Series<\/strong>: \u041e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DataFrame:<\/p>\n<pre><code class=\"python\">import pandas as pd  data = {    \"\u0418\u043c\u044f\": [\"\u0410\u043b\u0438\u0441\u0430\", \"\u0411\u043e\u0431\", \"\u0427\u0430\u0440\u043b\u0438\"],    \"\u0412\u043e\u0437\u0440\u0430\u0441\u0442\": [25, 30, 35],    \"\u0413\u043e\u0440\u043e\u0434\": [\"\u041c\u043e\u0441\u043a\u0432\u0430\", \"\u0421\u041f\u0431\", \"\u041a\u0430\u0437\u0430\u043d\u044c\"] }  df = pd.DataFrame(data) print(df)  # \u0412\u044b\u0432\u043e\u0434: # \u0418\u043c\u044f \u0412\u043e\u0437\u0440\u0430\u0441\u0442 \u0413\u043e\u0440\u043e\u0434 # 0 \u0410\u043b\u0438\u0441\u0430 25 \u041c\u043e\u0441\u043a\u0432\u0430 # 1 \u0411\u043e\u0431 30 \u0421\u041f\u0431 # 2 \u0427\u0430\u0440\u043b\u0438 35 \u041a\u0430\u0437\u0430\u043d\u044c <\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c: df[df[&#8216;\u0412\u043e\u0437\u0440\u0430\u0441\u0442&#8217;] &gt; 28], \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c: df.to_csv(&#8216;file.csv&#8217;).<\/p>\n<h3>4. \u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0451: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c requests \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f HTML \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, BeautifulSoup \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0438 pandas \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DataFrame. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043f\u0430\u0440\u0441\u0438\u043c \u0442\u043e\u043f-10 \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0441 IMDb (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0433\u043e\u0434\u044b \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0438 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438). URL: <a href=\"https:\/\/www.imdb.com\/chart\/top\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.imdb.com\/chart\/top\/<\/a>.<\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u0430\u0439\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u042d\u0442\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  import requests import pandas as pd import re   # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c HTML url = \"https:\/\/www.imdb.com\/chart\/top\/\" headers = {\"User-Agent\": \"Mozilla\/5.0\"}  # \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 (\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445) response = requests.get(url, headers=headers) html = response.text  soup = BeautifulSoup(html, \"html.parser\")  movies = [] items = soup.find_all(\"li\", class_=\"ipc-metadata-list-summary-item\", limit=10)  # \u0422\u043e\u043f-10  for item in items:     title_elem = item.find(\"h3\", class_=\"ipc-title__text\")     if title_elem:         # \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435         full_title = title_elem.text.strip()         match = re.match(r\"^\\d+\\.\\s*(.+?)\\s*\\((\\d{4})\\)\", full_title)         if match:             name = match.group(1)         else:             name = full_title     else:         name = \"N\/A\"      rating_elem = item.find(\"span\", class_=\"ipc-rating-star--imdb\")     rating = rating_elem.text.strip() if rating_elem else \"N\/A\"      movies.append({\"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\": name, \"\u0420\u0435\u0439\u0442\u0438\u043d\u0433\": rating})  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c DataFrame df = pd.DataFrame(movies) print(df) # \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430: #         \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435              \u0420\u0435\u0439\u0442\u0438\u043d\u0433 # 0  The Shawshank Redemption   9.3 # 1  The Godfather              9.2 # ... (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445)  # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 CSV df.to_csv(\"top10_movies.csv\", index=False) print(\"\u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 top10_movies.csv\") <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0430\u0440\u0441\u0438\u0442 \u0442\u043e\u043f-10 \u0444\u0438\u043b\u044c\u043c\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 regex \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438 \u0433\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 DataFrame, \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 CSV. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 IMDb \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<h4>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0441\u0442\u0430\u0442\u044c\u0435 \u0438 \u043e\u0431\u043e \u043c\u043d\u0435:<\/h4>\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u043e\u0434\u0430 \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435, \u0438\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0443 \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438\u044f\u0442\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f, \u0425\u0430\u0431\u0440!<\/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\/940144\/\"> https:\/\/habr.com\/ru\/articles\/940144\/<\/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<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python. \u041c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0443 HTML \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 BeautifulSoup, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 pandas \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043f \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0441 IMDb) \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 CSV-\u0444\u0430\u0439\u043b.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c \u043d\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <code>beautifulsoup4<\/code> <code>requests<\/code> <code>pandas<\/code> \u043d\u0430 python \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c python (\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u0441\u0438\u0438 3&gt; \u043d\u043e \u043c\u043d\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a\u0430\u044f \u0443 \u0432\u0430\u0441 \u0432\u0435\u0440\u0441\u0438\u044f).<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip: <code>pip install beautifulsoup4 requests pandas<\/code><\/p>\n<h3>1. \u041f\u0430\u0440\u0441\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/h3>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (regex) \u2014 \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c. \u0412 Python \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c re.<\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 email-\u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u0435\u0440\u0432\u044b\u0439 email.<\/p>\n<pre><code class=\"python\">import re  text = \"\u041c\u043e\u0438 emails: example@mail.com \u0438 test@domain.ru\" pattern = r\"\\b[A-Za-z0-9.\\_%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b\"  emails = re.findall(pattern, text)  print(emails[0]) # \u0412\u044b\u0432\u043e\u0434: example@mail.com <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0449\u0435\u0442 \u0442\u0438\u043f\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 email: \u0438\u043c\u044f@\u0434\u043e\u043c\u0435\u043d.\u0442\u043e\u0447\u043a\u0430.\u0434\u043e\u043c\u0435\u043d.<\/p>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0434\u0430\u0442\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0414\u0414.\u041c\u041c.\u0413\u0413\u0413\u0413 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e (\u0434\u0435\u043d\u044c \u043e\u0442 01 \u0434\u043e 31, \u043c\u0435\u0441\u044f\u0446 \u043e\u0442 01 \u0434\u043e 12).<\/p>\n<pre><code class=\"python\">import re  text = \"\u0414\u0430\u0442\u044b: 15.08.2023, 32.13.2024 (\u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f), 01.01.2025\" pattern = r\"\\b(0[1-9]|[12][0-9]|3[01])\\.(0[1-9]|1[0-2])\\.(20[0-9]{2})\\b\"  dates = re.findall(pattern, text)  print(dates) # \u0412\u044b\u0432\u043e\u0434: [('15', '08', '2023'), ('01', '01', '2025')] <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0434\u043b\u044f \u0434\u043d\u0435\u0439 \u0438 \u043c\u0435\u0441\u044f\u0446\u0435\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0434\u0430\u0442.<\/p>\n<h3>2. \u041f\u0430\u0440\u0441\u0438\u043c HTML (\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 BeautifulSoup)<\/h3>\n<p>BeautifulSoup \u2014 \u044d\u0442\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 HTML \u0438 XML \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0432\u0438\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0438\u0441\u043a\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0442\u0435\u0433\u0430\u043c, \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c. \u041a\u0440\u0430\u0442\u043a\u043e: \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 pip install beautifulsoup4, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u0440\u0441\u0435\u0440\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 &#8216;html.parser&#8217; \u0438\u043b\u0438 &#8216;lxml&#8217;.<\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e HTML.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  html = \"\"\" &lt;html&gt;  &lt;head&gt;&lt;title&gt;\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b&lt;\/title&gt;&lt;\/head&gt;  &lt;body&gt;&lt;h1&gt;\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a&lt;\/h1&gt;&lt;\/body&gt; &lt;\/html&gt; \"\"\"  soup = BeautifulSoup(html, \"html.parser\") title = soup.find(\"title\").text  print(title) # \u0412\u044b\u0432\u043e\u0434: \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 Soup \u0438 \u0438\u0449\u0435\u043c \u0442\u0435\u0433 title.<\/p>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h4>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0437 HTML \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c &#8216;link&#8217;.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  html = \"\"\" &lt;html&gt;   &lt;head&gt;&lt;title&gt;\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b&lt;\/title&gt;&lt;\/head&gt;   &lt;body&gt;&lt;h1&gt;\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a&lt;\/h1&gt;&lt;\/body&gt; &lt;\/html&gt; \"\"\"  soup = BeautifulSoup(html, \"html.parser\") title = soup.find(\"title\").text  print(title)  # \u0412\u044b\u0432\u043e\u0434: \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <\/code><\/pre>\n<p>\u041c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 href.<\/p>\n<h3>3. \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 pandas<\/h3>\n<p>Pandas \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 Python. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u043e\u0434\u0435 DataFrame (\u0442\u0430\u0431\u043b\u0438\u0446\u044b) \u0438 Series (\u0441\u0442\u043e\u043b\u0431\u0446\u044b), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 (CSV, Excel \u0438 \u0442.\u0434.), \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p><strong>DataFrame<\/strong>: \u0414\u0432\u0443\u043c\u0435\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Series<\/strong>: \u041e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DataFrame:<\/p>\n<pre><code class=\"python\">import pandas as pd  data = {    \"\u0418\u043c\u044f\": [\"\u0410\u043b\u0438\u0441\u0430\", \"\u0411\u043e\u0431\", \"\u0427\u0430\u0440\u043b\u0438\"],    \"\u0412\u043e\u0437\u0440\u0430\u0441\u0442\": [25, 30, 35],    \"\u0413\u043e\u0440\u043e\u0434\": [\"\u041c\u043e\u0441\u043a\u0432\u0430\", \"\u0421\u041f\u0431\", \"\u041a\u0430\u0437\u0430\u043d\u044c\"] }  df = pd.DataFrame(data) print(df)  # \u0412\u044b\u0432\u043e\u0434: # \u0418\u043c\u044f \u0412\u043e\u0437\u0440\u0430\u0441\u0442 \u0413\u043e\u0440\u043e\u0434 # 0 \u0410\u043b\u0438\u0441\u0430 25 \u041c\u043e\u0441\u043a\u0432\u0430 # 1 \u0411\u043e\u0431 30 \u0421\u041f\u0431 # 2 \u0427\u0430\u0440\u043b\u0438 35 \u041a\u0430\u0437\u0430\u043d\u044c <\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c: df[df[&#8216;\u0412\u043e\u0437\u0440\u0430\u0441\u0442&#8217;] &gt; 28], \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c: df.to_csv(&#8216;file.csv&#8217;).<\/p>\n<h3>4. \u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0451: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c requests \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f HTML \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, BeautifulSoup \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0438 pandas \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DataFrame. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043f\u0430\u0440\u0441\u0438\u043c \u0442\u043e\u043f-10 \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0441 IMDb (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0433\u043e\u0434\u044b \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0438 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438). URL: <a href=\"https:\/\/www.imdb.com\/chart\/top\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.imdb.com\/chart\/top\/<\/a>.<\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u0430\u0439\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u042d\u0442\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">from bs4 import BeautifulSoup  import requests import pandas as pd import re   # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c HTML url = \"https:\/\/www.imdb.com\/chart\/top\/\" headers = {\"User-Agent\": \"Mozilla\/5.0\"}  # \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 (\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445) response = requests.get(url, headers=headers) html = response.text  soup = BeautifulSoup(html, \"html.parser\")  movies = [] items = soup.find_all(\"li\", class_=\"ipc-metadata-list-summary-item\", limit=10)  # \u0422\u043e\u043f-10  for item in items:     title_elem = item.find(\"h3\", class_=\"ipc-title__text\")     if title_elem:         # \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435         full_title = title_elem.text.strip()         match = re.match(r\"^\\d+\\.\\s*(.+?)\\s*\\((\\d{4})\\)\", full_title)         if match:             name = match.group(1)         else:             name = full_title     else:         name = \"N\/A\"      rating_elem = item.find(\"span\", class_=\"ipc-rating-star--imdb\")     rating = rating_elem.text.strip() if rating_elem else \"N\/A\"      movies.append({\"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\": name, \"\u0420\u0435\u0439\u0442\u0438\u043d\u0433\": rating})  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c DataFrame df = pd.DataFrame(movies) print(df) # \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430: #         \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435              \u0420\u0435\u0439\u0442\u0438\u043d\u0433 # 0  The Shawshank Redemption   9.3 # 1  The Godfather              9.2 # ... (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445)  # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 CSV df.to_csv(\"top10_movies.csv\", index=False) print(\"\u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 top10_movies.csv\") <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0430\u0440\u0441\u0438\u0442 \u0442\u043e\u043f-10 \u0444\u0438\u043b\u044c\u043c\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 regex \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438 \u0433\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 DataFrame, \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 CSV. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 IMDb \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<h4>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0441\u0442\u0430\u0442\u044c\u0435 \u0438 \u043e\u0431\u043e \u043c\u043d\u0435:<\/h4>\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u043e\u0434\u0430 \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435, \u0438\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0443 \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438\u044f\u0442\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f, \u0425\u0430\u0431\u0440!<\/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\/940144\/\"> https:\/\/habr.com\/ru\/articles\/940144\/<\/a><br \/><\/br><\/br><\/p>\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-471948","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471948","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=471948"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471948\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}