Skip to content

想请教下,爬取的url信息储存到BDB中字段属性的相关说明 #51

Open

Activity

  1. yxssfxwzy commented on Nov 30, 2017

    @yxssfxwzy

    参考以下代码 :-)

    \cn\edu\hfut\dmic\webcollector\util\CrawlDatumFormater.java

    public static CrawlDatum jsonStrToDatum(String crawlDatumKey, String jsonStr) {
            JsonArray jsonArray = GsonUtils.parse(jsonStr).getAsJsonArray();
            CrawlDatum crawlDatum = new CrawlDatum();
            crawlDatum.key(crawlDatumKey);
            crawlDatum.url(jsonArray.get(0).getAsString());
            crawlDatum.setStatus(jsonArray.get(1).getAsInt());
            crawlDatum.setExecuteTime(jsonArray.get(2).getAsLong());
            crawlDatum.setExecuteCount(jsonArray.get(3).getAsInt());
            if (jsonArray.size() == 5) {
                JsonObject metaJsonObject = jsonArray.get(4).getAsJsonObject();
                crawlDatum.meta(metaJsonObject);
            }
            return crawlDatum;
        }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions