justhrun

headlinews_v2.pehape

Jun 12th, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. $url = 'http://www.idx.co.id/Home/ListedCompanies/Announcement/tabid/92/language/id-ID/Default.aspx';
  3. $ch = curl_init($url);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  5. curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  6. curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
  7. $str = curl_exec($ch);
  8. curl_close($ch);
  9.  
  10. $articles = array();
  11. $str = preg_replace("/\n+/","",$str);
  12. $str = preg_replace("/<br>/"," ",$str);
  13. $str = preg_replace("/\s+/"," ",$str);
  14. preg_match_all('/<span id="dnn_ctr519_MainView_rl1_ctrl[0-9]_lblDate">(.*?)<\/span>/si', $str, $tgl);
  15. preg_match_all('/style="color:#760605;font-size:12px;font-weight:bold;">(.*?)<\/a>/si', $str, $headline);
  16.    
  17. $i = 0;
  18. foreach( $tgl[1] as $tanggal ) {
  19.     $item = array();
  20.     $item['date'] = $tanggal;
  21.     $item['headline'] = $headline[1][$i];
  22.     $articles[] = $item;
  23.     $i++;
  24. }
  25. echo "<pre>\n";
  26. print_r($articles);
  27. echo "</pre>\n";   
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment