kettle HTTP client

來源:互聯網
上載者:User

標籤:

第一部分需要三個步驟:

  選擇輸入步驟,“產生記錄”,將步驟裡設定記錄數為1,並設定一個類型為String的欄位country(名字隨便),這個欄位的值應設定為我們要抽取資料的URL,如:

 

       然後,添加一個“HTTP 用戶端”步驟,並把這兩個步驟連起來。對於“HTTP 用戶端”來說,選擇“從欄位中擷取URL”(Accept URL from field)選項,並選擇country作為URL的來源欄位。

 

       選擇文字檔輸出,輸入檔案名稱及所需副檔名,選擇內容選項卡並根據需要修改,欄位選項卡擷取所需欄位。

 

第二部分需要三個步驟:

   選擇“json輸入”,瀏覽並增加檔案或路徑,讀取json檔案中的內容:

 

 

       選擇指令碼中的“Java代碼”,將解析出來的欄位中需要修改或者添加的部分進行必要修改。

 

private static int count = 0;

 

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException

{

    if (first){

      first = false;

    }

 

    Object[] r = getRow();

 

    if (r == null) {

      setOutputDone();

      return false;

    }

 

    // It is always safest to call createOutputRow() to ensure that your output row‘s Object[] is large

    // enough to handle any new fields you are creating in this step.

    r = createOutputRow(r, data.outputRowMeta.size());

   

    if(count== 0){

        String num_ID = "0";//get(Fields.In, "num_ID").getString(r);

        count = Integer.parseInt(num_ID);

    }

   

    get(Fields.In, "num_ID").setValue(r, ++count);

    // Send the row on to the next step.

    putRow(data.outputRowMeta, r);

 

    return true;

}

       最後,確認前面的步驟無誤後,選擇步驟表輸出:

 

kettle HTTP client

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.