昨天晚上無聊想做些事情, 於是就想把Readlnews_d.c 用好
以下範例是處理bahmut GNN的部份
首先使用 explode 將抓下來的資料以\n斷行, 在使用 regexp 取得相符合的字串
處理完這部份後剩下的lines就是我們要的資料
接下來使用foreach 去 sscanf 每一行把要的資料取出
這邊我們取出標題( line )和 時間 (time ), 再丟到news 的 bahamut type 存起來, 完成^^
- if( current_process->type == "bahamut" )
- {
- if( flag < 0 )
- {
- lines = explode(msg, "\n");
- lines = regexp(lines, "td nowrap"); // Catch All Hyperlink
- news[current_process->type] = allocate(2);
- news[current_process->type][0] = allocate(0);
- foreach(string line in lines)
- {
- 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);
- news[current_process->type][0] += ({ sprintf("%s (%s)", line, time) });
- i++;
- }
- return;
- }
- }
0 Responses to “Readlnews_d.c”