Ejemplo n.º 1
0
  private boolean Connect(String Address) {

    for (int Retry = 0; (doc == null) && (Retry < Res.getRetrytimes()); Retry++) {
      try {

        doc = Jsoup.connect(Address).userAgent("Mozilla").timeout(Res.geTimeOut()).get();

      } catch (IOException e) {

        Log.print("FetchCnblogs::Connect", Res.getConRetryMsg() + "第" + (Retry + 1) + "次");
      }
    }

    if (doc == null) return false;
    else return true;
  }
Ejemplo n.º 2
0
  /** get post body and fetch the image links */
  @Override
  public void getContent(ItemInfo item) {
    Document adoc = null;
    for (int j = 0; adoc == null && j < Res.getRetrytimes(); j++) {
      System.out.println("Startting fetching contets of" + item.getItemName());
      try {
        adoc =
            Jsoup.connect(item.getItemLink()).userAgent("Mozilla").timeout(Res.geTimeOut()).get();
      } catch (IOException e) {

        System.out.println(Res.getConRetryMsg());
      }
    }
    if (adoc == null) {
      System.out.println("fetch tips error, adoc is null");
      item.setContent(Res.getFileNotExistMsg());
    } else {
      item.setContent(adoc.getElementsByClass("post").html());
    }
  }