Readlnews_d.c

昨天晚上無聊想做些事情, 於是就想把Readlnews_d.c 用好

以下範例是處理bahmut GNN的部份

首先使用 explode 將抓下來的資料以\n斷行, 在使用 regexp 取得相符合的字串

處理完這部份後剩下的lines就是我們要的資料

接下來使用foreach 去 sscanf 每一行把要的資料取出

這邊我們取出標題( line )和 時間 (time ), 再丟到news 的 bahamut type 存起來, 完成^^

  1. if( current_process->type == "bahamut" )
  2. {
  3.     if( flag < 0 )
  4.     {
  5.         lines = explode(msg, "\n");
  6.         lines = regexp(lines, "td nowrap"); // Catch All Hyperlink
  7.  
  8.         news[current_process->type] = allocate(2);
  9.         news[current_process->type][0] = allocate(0);
  10.         foreach(string line in lines)
  11.         {
  12.             sscanf(line, "<tr><td width=%*s><img src=%*s></td><td nowrap><a class=%*s>%s</a> (%s) </td></tr><tr><%*s></td></tr>", line, time);
  13.             news[current_process->type][0] += ({ sprintf("%s (%s)", line, time) });
  14.             i++;
  15.         }
  16.         return;
  17.     }
  18. }

0 Responses to “Readlnews_d.c”


  1. No Comments

Leave a Reply




  • 額外資訊

  • 網路相簿

  • 好友的Blog

  • 好友的網站

  • 部落格觀察

    BlogLook Score and Rank

  • Bad Behavior has blocked 1336 access attempts in the last 7 days.