{"id":160815,"date":"2012-11-30T10:25:03","date_gmt":"2012-11-30T06:25:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=160815"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=160815","title":{"rendered":"<span class=\"post_title\">Tweetter \u0431\u043e\u0442 \u0434\u043b\u044f Freelansim<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c.<br \/>  \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0431\u043e\u0442\u043e\u043c \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u0430 freelansim.ru <a href=\"https:\/\/twitter.com\/freelansimru\">twitter.com\/freelansimru<\/a><br \/>  <a name=\"habracut\"><\/a><\/p>\n<pre><code class=\"php\">#!\/usr\/bin\/php  -q &lt;? \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 include 'lib\/simple_html_dom.php'; include 'lib\/twitteroauth.php'; include 'lib\/Array_Capable_PDO.php';  \/\/ \u043a\u043e\u043d\u0435\u043a\u0442\u0438\u043c\u0441\u044f \u043a \u0431\u0434 try {     $DBH = new Array_Capable_PDO(&quot;mysql:host=database_ip;dbname=parser&quot;, 'username', 'password'); } catch(PDOException $e) {     echo $e-&gt;getMessage();     die; }  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a id \u043d\u043e\u0432\u044b\u0445 \u0442\u0430\u0441\u043a\u043e\u0432 \u0441 freelansim.ru $html = file_get_html('http:\/\/freelansim.ru\/tasks'); $tasks = $html-&gt;find('.task'); $ids=array();  foreach($tasks as $ts) {     $ids[] = str_replace('\/tasks\/','',$ts-&gt;children(2)-&gt;children(0)-&gt;href); } \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0430\u0441\u043a\u043e\u0432 \u0432 \u0431\u0434 $STH = $DBH-&gt;prepare_with_arrays(     'SELECT group_concat(id) as ids from freelansim where id in :ids',     array(':ids'),     array($ids) ); $STH-&gt;setFetchMode(PDO::FETCH_ASSOC); $STH-&gt;execute();  $res = $STH-&gt;fetch(); if($res['ids']!=null)     $db_ids = explode(',',$res['ids']); else     $db_ids = array();  \/\/\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c api tweetter $oauth = new TwitterOAuth('TWITTER_KEY', 'TWITTER_SECRET', 'accessToken', 'accessSecret'); $credentials = $oauth-&gt;get(&quot;account\/verify_credentials&quot;);  foreach($ids as $i){      \/\/ \u0415\u0441\u043b\u0438 id \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u0435 \u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043c     if(in_array($i,$db_ids)) continue;      \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0430\u0441\u043a\u0430     $details = file_get_html('http:\/\/freelansim.ru\/tasks\/'.$i);      $d = $details-&gt;find('.more_information');     $t = $details-&gt;find('.short_info');      $title = $t[0]-&gt;children(1)-&gt;children(0)-&gt;innertext.&quot;\\n&quot;;     $price= $t[0]-&gt;children(2)-&gt;children(0)-&gt;innertext.&quot;\\n&quot;;     $suffix= $t[0]-&gt;children(2)-&gt;children(1)-&gt;innertext.&quot;\\n&quot;;     $descr= $d[0]-&gt;children(0)-&gt;children(2)-&gt;innertext.&quot;\\n&quot;;      \/\/ \u043f\u0438\u0448\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0430\u0441\u043a\u0430 \u0432 \u0431\u0434     $STH = $DBH-&gt;prepare(&quot;INSERT INTO freelansim (id, title, descr, price, suffix) values (?, ?, ?, ?, ?)&quot;);     $STH-&gt;bindParam(1, $i);     $STH-&gt;bindParam(2, $title);     $STH-&gt;bindParam(3, $descr);     $STH-&gt;bindParam(4, $price);     $STH-&gt;bindParam(5, $suffix);     $STH-&gt;execute();          \/\/ \u0438 \u043f\u043e\u0441\u0442\u0438\u043c \u0432 \u0442\u0432\u0438\u0442\u0442\u0435\u0440     $msg = &quot;$title $price $suffix http:\/\/mixgift.ru\/r.php?i=$i #freelansim&quot;;     $oauth-&gt;post('statuses\/update', array('status' =&gt; $msg)); }  ?&gt;  <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<br \/>  <a href=\"http:\/\/vexell.ru\/2011\/03\/%D0%BF%D0%B8%D1%88%D0%B5%D0%BC-%D0%B1%D0%BE%D1%82%D0%B0-%D0%BD%D0%B0-php-%D0%B4%D0%BB%D1%8F-twitter-%D0%B8%D0%BB%D0%B8-%D0%BA%D0%B0%D0%BA-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C\/\">\u041f\u0438\u0448\u0435\u043c \u0431\u043e\u0442\u0430 tweetter<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/114143\/\">\u041f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430 php<\/a><br \/>  <a href=\"http:\/\/stackoverflow.com\/questions\/920353\/php-pdo-can-i-bind-an-array-to-an-in-condition\">\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 PDO<\/a>    \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\/160815\/\"> http:\/\/habrahabr.ru\/post\/160815\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c.<br \/>  \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0431\u043e\u0442\u043e\u043c \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u0430 freelansim.ru <a href=\"https:\/\/twitter.com\/freelansimru\">twitter.com\/freelansimru<\/a>  <\/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-160815","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/160815","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=160815"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/160815\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}