예제 #1
0
  public static Apk getApkDetail(Page page) {
    // 获取dom对象
    Html html = page.getHtml();

    // 找出对应需要信息
    String appDetailUrl = page.getUrl().toString();
    String appName = html.xpath("//div[@class='rightbox']/h1/text()").toString();
    String appVersion =
        StringUtils.substringAfter(html.xpath("//div[@class='leftbox']/p[1]/text()").get(), ":");
    String appDownloadUrl =
        html.xpath("//div[@class='leftbox']/a[@class='down_btn']/@href").toString();
    String osPlatform =
        StringUtils.substringAfter(html.xpath("//div[@class='leftbox']/p[7]/text()").get(), ":");
    String appSize =
        StringUtils.substringAfter(html.xpath("//div[@class='leftbox']/p[2]/text()").get(), ":");
    String appUpdateDate =
        StringUtils.substringAfter(html.xpath("//div[@class='leftbox']/p[6]/text()").get(), ":");
    String appType = null;

    String appDescription = html.xpath("//div[@id='txtover']/p/text()").get();
    List<String> appScreenshot = html.xpath("//ul[@class='view_gameimgli']/li/a/img/@src").all();
    String appTag = null;
    String appCategory = html.xpath("//div[@class='cont_title cont_title3']/a[3]/text()").get();
    String appCommentUrl = null;
    String appComment = null;
    String dowloadNum = null;

    Apk apk = null;
    if (null != appName && null != appDownloadUrl) {
      apk =
          new Apk(
              appName,
              appDetailUrl,
              appDownloadUrl,
              osPlatform,
              appVersion,
              appSize,
              appUpdateDate,
              null != appType ? appType : "APK");
      apk.setAppDescription(appDescription);
      apk.setAppScreenshot(appScreenshot);
      apk.setAppCommentUrl(appCommentUrl);
      apk.setAppComment(appComment);
      apk.setAppDownloadTimes(dowloadNum);
      apk.setAppCategory(appCategory);
      apk.setAppTag(appTag);
    }

    LOGGER.debug(
        "name:{}, version: {}, url:{}, size: {}, appType: {}, os: {}, date:{}, downlaodNum:{}, , appTag:{}, appCategory:{}"
            + ", appScreenhost:{}, appCommentUrl:{}, appComment:{}, appDescription:{}",
        appName,
        appVersion,
        appDownloadUrl,
        appSize,
        appType,
        osPlatform,
        appUpdateDate,
        dowloadNum,
        appTag,
        appCategory,
        appScreenshot,
        appCommentUrl,
        appComment,
        appDescription);

    return apk;
  }
예제 #2
0
  public static Apk getApkDetail(Page page) {
    // 获取dom对象
    Html html = page.getHtml();

    // 找出对应需要信息
    String appDetailUrl = page.getUrl().toString();
    String appName = html.xpath("//div[@class='left_icon']/h1/text()").toString();
    String appVersion = html.xpath("//div[@class='left_icon']/h2/text()").toString();
    String appDownloadUrl = html.xpath("//div[@class='bottom_down']/a/@href").toString();
    String osPlatform = null;
    String appSize = html.xpath("//div[@class='xinxi_center']/p[3]/span/text()").toString();
    String appUpdateDate = html.xpath("//div[@class='xinxi_center']/p[7]/span/text()").toString();
    String appType = null;

    String appDescription = html.xpath("//div[@class='jianjie_cent']/p/text()").get();
    List<String> appScreenshot = html.xpath("//div[@class='snapShotCont']/div/img/@src").all();
    String appTag = null;
    String appCategory = null;
    String appCommentUrl = null;
    String appComment = null;
    String dowloadNum = html.xpath("//div[@class='xinxi_center']/p[4]/span/text()").toString();
    ;

    Apk apk = null;
    if (null != appName && null != appDownloadUrl) {
      apk =
          new Apk(
              appName,
              appDetailUrl,
              appDownloadUrl,
              osPlatform,
              appVersion,
              appSize,
              appUpdateDate,
              null != appType ? appType : "APK");
      apk.setAppDescription(appDescription);
      apk.setAppScreenshot(appScreenshot);
      apk.setAppCommentUrl(appCommentUrl);
      apk.setAppComment(appComment);
      apk.setAppDownloadTimes(dowloadNum);
      apk.setAppCategory(appCategory);
      apk.setAppTag(appTag);
    }

    LOGGER.debug(
        "name:{}, version: {}, url:{}, size: {}, appType: {}, os: {}, date:{}, downlaodNum:{}, , appTag:{}, appCategory:{}"
            + ", appScreenhost:{}, appCommentUrl:{}, appComment:{}, appDescription:{}",
        appName,
        appVersion,
        appDownloadUrl,
        appSize,
        appType,
        osPlatform,
        appUpdateDate,
        dowloadNum,
        appTag,
        appCategory,
        appScreenshot,
        appCommentUrl,
        appComment,
        appDescription);

    return apk;
  }