fix process

This commit is contained in:
snoop 2017-05-17 14:10:47 +09:00
parent e3ceccd14b
commit b62b0e0f2e

View File

@ -3,9 +3,11 @@ package com.loafle.overflow.crawler;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.loafle.overflow.crawler.config.Config; import com.loafle.overflow.crawler.config.Config;
import com.loafle.overflow.crawler.result.OFResultSet;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -32,7 +34,21 @@ public abstract class Crawler {
return true; return true;
} }
public Object get(String id) throws Exception { public Object get(String id) throws Exception {
return getInternal(getConfig(id));
List<OFResultSet> rsList = (List<OFResultSet>)getInternal(getConfig(id));
Map<String, String> rm = new HashMap<>();
Map<String, String> m = null;
for (OFResultSet rs : rsList) {
m = rs.getData();
rm.putAll(m);
}
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(rm);
return json.getBytes();
} }
public Object init(byte [] data) throws Exception { public Object init(byte [] data) throws Exception {
add(data); add(data);