{"id":313188,"date":"2020-11-15T21:02:29","date_gmt":"2020-11-15T21:02:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=313188"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=313188","title":{"rendered":"\u0421\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0432 Apache Kafka"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a \u0436\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u0430\u043c\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438. \u0410 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0449\u0435 \u0438 \u0440\u0435\u0434\u043a\u0438.<br \/>  \u0418\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435: <a href=\"https:\/\/developer.twitter.com\/en\/docs\/twitter-api\/getting-started\/guide\" rel=\"nofollow\">twitter<\/a>, <a href=\"https:\/\/vk.com\/dev\/methods\" rel=\"nofollow\">vk<\/a>. \u041d\u043e \u044d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043d\u0435 \u043f\u043e\u0434 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<br \/>  \u0415\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u043e \u044d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043d\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0435. \u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0441\u044b\u043b\u043a\u0438: <a href=\"https:\/\/github.com\/public-apis\/public-apis\" rel=\"nofollow\">public-apis<\/a>.<br \/>  \u041f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<br \/>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a.<br \/>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c: <a href=\"https:\/\/www.imdb.com\/\" rel=\"nofollow\">imdb<\/a>.<br \/>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <a href=\"https:\/\/www.imdb.com\/\" rel=\"nofollow\">imdb<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0421\u043c. <a href=\"https:\/\/www.imdb.com\/interfaces\/\" rel=\"nofollow\">IMDb Datasets<\/a>. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u042f\u0437\u044b\u043a: Java 1.8.<br \/>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: kafka 2.6.0, jsoup 1.13.1.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"sbor-dannyh\">\u0421\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>  <\/p>\n<p>\u0421\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 html-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0438\u0449\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<br \/>  \u0418\u0442\u0430\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445: <a href=\"https:\/\/www.imdb.com\/\" rel=\"nofollow\">imdb<\/a>. \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043e \u0444\u0438\u043b\u044c\u043c\u0430\u0445 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441: <a href=\"https:\/\/www.imdb.com\/search\/title\/?release_date=%s,%s&amp;countries=%s\" rel=\"nofollow\">https:\/\/www.imdb.com\/search\/title\/?release_date=%s,%s&amp;countries=%s<\/a><br \/>  \u0413\u0434\u0435 1, 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2013 \u044d\u0442\u043e \u0434\u0430\u0442\u044b. 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2013 \u0441\u0442\u0440\u0430\u043d\u044b.<br \/>  \u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443: <a href=\"https:\/\/www.kaggle.com\/stefanoleone992\/imdb-extensive-dataset\" rel=\"nofollow\">imdb-extensive-dataset<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public interface MovieDirectScrapingService {     Collection&lt;Movie&gt; scrap(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 Movie \u2013 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0444\u0438\u043b\u044c\u043c\u0435 (\u0438\u043b\u0438 \u043e \u0448\u043e\u0443 \u0438 \u0442.\u043f.).<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class Movie {     public final String titleId;     public final String titleUrl;     public final String title;     public final String description;     public final Double rating;     public final String genres;     public final String runtime;     public final String baseUrl;     public final String baseNameUrl;     public final String baseTitleUrl;     public final String participantIds;     public final String participantNames;     public final String directorIds;     public final String directorNames; \u2026<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.<br \/>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e jsoup. \u0414\u0430\u043b\u0435\u0435 \u0438\u0449\u0443\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 html-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u043c\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">String scrap(String url, List&lt;Movie&gt; items) {     Document doc = null;     try {         doc = Jsoup.connect(url).header(&quot;Accept-Language&quot;, language).get();     } catch (IOException e) {         e.printStackTrace();     }     if (doc != null) {         collectItems(doc, items);         return nextUrl(doc);     }     return &quot;&quot;; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0438\u0441\u043a \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">String nextUrl(Document doc) {     Elements nextPageElements = doc.select(&quot;.next-page&quot;);     if (nextPageElements.size() &gt; 0) {         Element hrefElement = nextPageElements.get(0);         return baseUrl + hrefElement.attributes().get(&quot;href&quot;);     }     return &quot;&quot;; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c. \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u0417\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430, \u0442\u043e \u0438\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043d\u0435\u0439. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public Collection&lt;Movie&gt; scrap() {     String url = String.format(             baseUrl + &quot;\/search\/title\/?release_date=%s,%s&amp;countries=%s&quot;,             startDate, endDate, countries     );     List&lt;Movie&gt; items = new ArrayList&lt;&gt;();     String nextUrl = url;     while (true) {         nextUrl = scrap(nextUrl, items);         if (&quot;&quot;.equals(nextUrl)) {             break;         }         try {             Thread.sleep(50);         } catch (InterruptedException e) {         }     }     return items; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0441\u044b\u043b\u043a\u0430\u0445 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>  <\/p>\n<h1 id=\"otpravka-dannyh-v-topik\">\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u043a<\/h1>\n<p>  <\/p>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441: MovieProducer. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434: run.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0444\u043a\u0438. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430. \u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043f\u0438\u043a.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public void run() {     try (SimpleStringStringProducer producer = new SimpleStringStringProducer(             bootstrapServers, clientId, topic)) {         Collection&lt;Data.Movie&gt; movies = movieDirectScrapingService.scrap();         List&lt;SimpleStringStringProducer.KeyValueStringString&gt; kvList = new ArrayList&lt;&gt;();         for (Data.Movie move : movies) {             Map&lt;String, String&gt; map = new HashMap&lt;&gt;();             map.put(&quot;title_id&quot;, move.titleId);             map.put(&quot;title_url&quot;, move.titleUrl);             \u2026             String value = JSONObject.toJSONString(map);             String key = UUID.randomUUID().toString();             kvList.add(new SimpleStringStringProducer.KeyValueStringString(key, value));         }         producer.produce(kvList);     } }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"teper-vse-vmeste\">\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435<\/h1>\n<p>  <\/p>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043f\u0438\u043a.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441: MovieDirectScrapingExecutor. \u0421 \u043e\u0434\u043d\u0438\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c: run.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u043a.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public void run() {     int countriesCounter = 0;     List&lt;String&gt; countriesSource = Arrays.asList(&quot;us&quot;);      while (true) {         try {             LocalDate localDate = LocalDate.now();              int year = localDate.getYear();             int month = localDate.getMonthValue();             int day = localDate.getDayOfMonth();              String monthString = month &lt; 9 ? &quot;0&quot; + month : Integer.toString(month);             String dayString = day &lt; 9 ? &quot;0&quot; + day : Integer.toString(day);              String startDate = year + &quot;-&quot; + monthString + &quot;-&quot; + dayString;             String endDate = startDate;              String language = &quot;en&quot;;             String countries = countriesSource.get(countriesCounter);              execute(language, startDate, endDate, countries);              Thread.sleep(1000);              countriesCounter += 1;             if (countriesCounter &gt;= countriesSource.size()) {                 countriesCounter = 0;             }          } catch (InterruptedException e) {         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 MovieDirectScrapingExecutor, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 main.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u043c\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">{   &quot;base_name_url&quot;: &quot;https:\\\/\\\/www.imdb.com\\\/name&quot;,   &quot;participant_ids&quot;: &quot;nm7947173~nm2373827~nm0005288~nm0942193~&quot;,   &quot;title_id&quot;: &quot;tt13121702&quot;,   &quot;rating&quot;: &quot;0.0&quot;,   &quot;base_url&quot;: &quot;https:\\\/\\\/www.imdb.com&quot;,   &quot;description&quot;: &quot;It's Christmas time and Jackie (Carly Hughes), an up-and-coming journalist, finds that her life is at a crossroads until she finds an unexpected opportunity - to run a small-town newspaper ... See full summary \u00bb&quot;,   &quot;runtime&quot;: &quot;&quot;,   &quot;title&quot;: &quot;The Christmas Edition&quot;,   &quot;director_ids&quot;: &quot;nm0838289~&quot;,   &quot;title_url&quot;: &quot;\\\/title\\\/tt13121702\\\/?ref_=adv_li_tt&quot;,   &quot;director_names&quot;: &quot;Peter Sullivan~&quot;,   &quot;genres&quot;: &quot;Drama, Romance&quot;,   &quot;base_title_url&quot;: &quot;https:\\\/\\\/www.imdb.com\\\/title&quot;,   &quot;participant_names&quot;: &quot;Carly Hughes~Rob Mayes~Marie Osmond~Aloma Wright~&quot; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0441\u044b\u043b\u043a\u0430\u0445 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>  <\/p>\n<h1 id=\"testy\">\u0422\u0435\u0441\u0442\u044b<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f kafka-\u0441\u0435\u0440\u0432\u0435\u0440.<br \/>  \u0421\u043c. <a href=\"https:\/\/habr.com\/ru\/post\/527712\/\">Apache Kafka \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 Kafka Server<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c \u0442\u0435\u0441\u0442: MovieProducerTest.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public class MovieProducerTest {     @Test     void simple() throws InterruptedException {         String brokerHost = &quot;127.0.0.1&quot;;         int brokerPort = 29092;         String zooKeeperHost = &quot;127.0.0.1&quot;;         int zooKeeperPort = 22183;         String bootstrapServers = brokerHost + &quot;:&quot; + brokerPort;         String topic = &quot;q-data&quot;;         String clientId = &quot;simple&quot;;         try (KafkaServerService kafkaServerService = new KafkaServerService(                 brokerHost, brokerPort, zooKeeperHost, zooKeeperPort         )         ) {             kafkaServerService.start();             kafkaServerService.createTopic(topic);              MovieDirectScrapingService movieDirectScrapingServiceImpl = () -&gt; Collections.singleton(                     new Data.Movie(\u2026)             );             MovieProducer movieProducer =                     new MovieProducer(bootstrapServers, clientId, topic, movieDirectScrapingServiceImpl);             movieProducer.run();              kafkaServerService.poll(topic, &quot;simple&quot;, 1, 5, (records) -&gt; {                 assertTrue(records.count() &gt; 0);                 ConsumerRecord&lt;String, String&gt; record = records.iterator().next();                 JSONParser jsonParser = new JSONParser();                 JSONObject jsonObject = null;                 try {                     jsonObject = (JSONObject) jsonParser.parse(record.value());                 } catch (ParseException e) {                     e.printStackTrace();                 }                 assertNotNull(jsonObject);         \u2026             });              Thread.sleep(5000);         }     } }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0437\u0434\u0435\u0441\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041d\u043e \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u0432 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0439\u0442\u0438.<\/p>\n<p>  <\/p>\n<h1 id=\"ssylki-i-resursy\">\u0421\u0441\u044b\u043b\u043a\u0438 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/kartzum\/intro_to_apache_kafka\/tree\/main\/story\/resources\/k-plain-sources\" rel=\"nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>.<\/p>\n<\/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\/post\/528134\/\"> https:\/\/habr.com\/ru\/post\/528134\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a \u0436\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u0430\u043c\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438. \u0410 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0449\u0435 \u0438 \u0440\u0435\u0434\u043a\u0438.<br \/>  \u0418\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435: <a href=\"https:\/\/developer.twitter.com\/en\/docs\/twitter-api\/getting-started\/guide\" rel=\"nofollow\">twitter<\/a>, <a href=\"https:\/\/vk.com\/dev\/methods\" rel=\"nofollow\">vk<\/a>. \u041d\u043e \u044d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043d\u0435 \u043f\u043e\u0434 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<br \/>  \u0415\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u043e \u044d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043d\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0435. \u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0441\u044b\u043b\u043a\u0438: <a href=\"https:\/\/github.com\/public-apis\/public-apis\" rel=\"nofollow\">public-apis<\/a>.<br \/>  \u041f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<br \/>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a.<br \/>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c: <a href=\"https:\/\/www.imdb.com\/\" rel=\"nofollow\">imdb<\/a>.<br \/>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <a href=\"https:\/\/www.imdb.com\/\" rel=\"nofollow\">imdb<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0421\u043c. <a href=\"https:\/\/www.imdb.com\/interfaces\/\" rel=\"nofollow\">IMDb Datasets<\/a>. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u042f\u0437\u044b\u043a: Java 1.8.<br \/>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: kafka 2.6.0, jsoup 1.13.1.<\/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-313188","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313188","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=313188"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313188\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}