- 生成记录
- Http Rest
- Java代码
特别注意:Element在这里用不了,报错,必须用Elements
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
if (first) {
first = false;
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
String url = "https://policy.smejs.cn/frontend/policy-service/7eb3545b15ee474a96af7b34d24ab807";
try {
// Jsoup解析处理
Connection conn = Jsoup.connect(url);
Document doc = conn.timeout(10000).get();
Elements ul = doc.select("div.policy-info-detail-page__main__top__line__value");
get(Fields.Out, "doc").setValue(r, ul.get(2));
} catch (IOException e) {
e.printStackTrace();
}
// Send the row on to the next step.
putRow(data.outputRowMeta, r);
return true;
}
-
写日志
-
结果
成功~