justhrun

headlinews.pehape

Jun 11th, 2015
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. $url = 'http://www.idx.co.id/Home/ListedCompanies/Announcement/tabid/92/language/id-ID/Default.aspx';
  3. include('simple_html_dom.php');
  4. $html = new simple_html_dom();
  5. $ch = curl_init($url);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  7. curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  8. 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");
  9. $html->load(curl_exec($ch));
  10. curl_close($ch);
  11.  
  12. $articles = array();
  13. foreach($html->find('div[class="tempat_list_berita"]') as $str) {
  14.     $str = preg_replace("/\n+/","",$str);
  15.     $str = preg_replace("/<br>/"," ",$str);
  16.     $str = preg_replace("/\s+/"," ",$str);
  17.     preg_match_all('/<span id="dnn_ctr519_MainView_rl1_ctrl[0-9]_lblDate">(.*?)<\/span>/si', $str, $tgl);
  18.     preg_match_all('/style="color:#760605;font-size:12px;font-weight:bold;">(.*?)<\/a>/si', $str, $headline);
  19.    
  20.     $i = 0;
  21.     foreach( $tgl[1] as $tanggal ) {
  22.         $item = array();
  23.         $item['date'] = $tanggal;
  24.         $item['headline'] = $headline[1][$i];
  25.         $articles[] = $item;
  26.         $i++;
  27.     }
  28. }
  29. echo "<pre>\n";
  30. print_r($articles);
  31. echo "</pre>\n";   
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment