{"id":157185,"date":"2012-11-02T17:15:08","date_gmt":"2012-11-02T13:15:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=157185"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=157185","title":{"rendered":"<span class=\"post_title\">\u0421\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0431\u043e\u0440\u043e\u0432-2012 \u043d\u0430 \u0423\u043a\u0440\u0430\u0438\u043d\u0435 (\u043f\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0443\u043c\u0431\u0443\u0440\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0435-\u0433\u0434\u0435 \u0448\u0438\u043b\u043e \u0437\u0430\u043a\u043e\u043b\u043e\u043b\u043e, \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c (\u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0438\u0434\u0435).<\/p>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u043d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0443 \u043d\u0430\u0441 (\u043d\u0430 \u0423\u043a\u0440\u0430\u0438\u043d\u0435) \u0438\u0434\u0443\u0442 \u0432\u044b\u0431\u043e\u0440\u044b (\u0442\u043e\u0447\u043d\u0435\u0435, \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432); \u0438\u0434\u0443\u0442 \u0442\u0443\u0433\u043e. \u041b\u0435\u043d\u044c \u0436\u0434\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0441\u0435\u0439\u0447\u0430\u0441. \u0421 \u0441\u0430\u0439\u0442\u0430 \u0446\u0435\u043d\u0442\u0440\u0438\u0437\u0431\u0438\u0440\u043a\u043e\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u043c php-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u044c\u044e\u0442\u0441\u044f \u0432 \u0411\u0414, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f.<a name=\"habracut\"><\/a><\/p>\n<p>  <a href=\"https:\/\/docs.google.com\/open?id=0B3JjNKiSQCVgUFhfajVtS01ZWFE\">\u0422\u0443\u0442<\/a> \u0434\u0430\u043d\u043d\u044b\u0435 (\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 SQL \u0447\u0435\u0440\u0435\u0437 PMA)<br \/>  <a href=\"https:\/\/docs.google.com\/open?id=0B3JjNKiSQCVgeGVPUndRZ3RzSk0\">\u0422\u0443\u0442<\/a> \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0411\u0414 (\u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0441\u043b\u0438\u0432\u0430\u0442\u044c).<\/p>\n<p>  \u041a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0441\u0442\u0438\u0442\u0435 \u0431\u044b\u0434\u043b\u043e\u043a\u043e\u0434\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">#!\/usr\/bin\/php &lt;?php $num = 225; $url = 'http:\/\/www.cvk.gov.ua\/vnd2012\/wp336pt001f01=900pf7331=%s.html'; $doc = new \\DOMDocument;  $pdo = new PDO('mysql:host=localhost;dbname=vybory', 'vybory', 'vybory');  for ($i = 1; $i &lt;= $num; $i++) { \techo '\u041e\u043a\u0440\u0443\u0433 ' . $i . &quot;\\n&quot;; \t$page = sprintf($url, $i);  \t$code = file_get_contents($page); \t$doc-&gt;loadHTML($code);  \t$xpath = new \\DOMXpath($doc); \t$table = $xpath-&gt;query('\/\/div[@id=&quot;restab&quot;]\/table')-&gt;item(0); \tforeach ($table-&gt;childNodes as $node) { \t\t$id = trim($node-&gt;childNodes-&gt;item(0)-&gt;nodeValue); \t\tif (!is_numeric($id)) { \t\t\tcontinue; \t\t} \t\t$perc = trim($node-&gt;childNodes-&gt;item(2)-&gt;nodeValue) \/ \t\t        trim($node-&gt;childNodes-&gt;item(1)-&gt;nodeValue); \t\t$pdo-&gt;exec('insert into uchastok (perc, num, okrug) values (&quot;' . $perc . '&quot;, &quot;' . $id . '&quot;, &quot;' . $i . '&quot;)'); \t\t$id = $pdo-&gt;lastInsertId();  \t\t$pdo-&gt;beginTransaction(); \t\tfor ($j = 3; $j &lt; $node-&gt;childNodes-&gt;length; $j++) { \t\t\t$c = $node-&gt;childNodes-&gt;item($j)-&gt;nodeValue; \t\t\t$c = (int)trim($c); \t\t\t$pdo-&gt;exec('insert into data (id_uchastok, id_party, data) values (&quot;' . $id . '&quot;, &quot;' . ($j - 2) . '&quot;, &quot;' . $c . '&quot;)'); \t\t} \t\t$pdo-&gt;commit(); \t} }  echo &quot;\\n&quot;; exit(0); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430, \u043a\u043e\u0434 \u0441\u0442\u0440\u0451\u043c\u043d\u044b\u0439. \u0414\u0430, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0440\u043e\u0434\u0435 \u00abuchastok\u00bb \u0440\u0435\u0436\u0443\u0442 \u0433\u043b\u0430\u0437\u0430. \u041f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0430\u0442\u044c, \u0430 \u0442\u0430\u043c, \u043c\u043e\u0436\u0435\u0442, \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e-\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0444\u043e\u0440\u043c\u0438\u0442. \u0421\u0430\u043c\u043e-\u0441\u043e\u0431\u043e\u0439, \u043b\u044e\u0431\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.    \t   \t<\/p>\n<div class=\"clear\"><\/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=\"http:\/\/habrahabr.ru\/post\/157185\/\"> http:\/\/habrahabr.ru\/post\/157185\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0443\u043c\u0431\u0443\u0440\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0435-\u0433\u0434\u0435 \u0448\u0438\u043b\u043e \u0437\u0430\u043a\u043e\u043b\u043e\u043b\u043e, \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c (\u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0438\u0434\u0435).<\/p>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u043d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0443 \u043d\u0430\u0441 (\u043d\u0430 \u0423\u043a\u0440\u0430\u0438\u043d\u0435) \u0438\u0434\u0443\u0442 \u0432\u044b\u0431\u043e\u0440\u044b (\u0442\u043e\u0447\u043d\u0435\u0435, \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432); \u0438\u0434\u0443\u0442 \u0442\u0443\u0433\u043e. \u041b\u0435\u043d\u044c \u0436\u0434\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0441\u0435\u0439\u0447\u0430\u0441. \u0421 \u0441\u0430\u0439\u0442\u0430 \u0446\u0435\u043d\u0442\u0440\u0438\u0437\u0431\u0438\u0440\u043a\u043e\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u043c php-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u044c\u044e\u0442\u0441\u044f \u0432 \u0411\u0414, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f.<\/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-157185","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157185","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=157185"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157185\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}