コード例 #1
0
ファイル: TopicApi.java プロジェクト: slartus/4pda.Nitro
  /**
   * Получение топика
   *
   * @param client - клиент
   * @param topicUrl - ссылка на топик
   * @return
   * @throws IOException
   */
  public static TopicResult getTopic(IHttpClient client, CharSequence topicUrl) throws IOException {
    TopicResult topicResult = new TopicResult();

    String topicBody = client.performGet(normalizeTopicUrl(topicUrl).toString());
    topicResult.parseUrl(client.getRedirectUrl());

    Matcher mainMatcher =
        Pattern.compile(
                "([\\s\\S]*?)(<div class=\"pagination\">.[\\s\\S]*?<div class=\"pagination\">.*?</div>)")
            .matcher(topicBody);
    checkTopicResult(topicUrl, topicResult.getTopicId(), topicBody, mainMatcher);

    topicResult.parseHeader(mainMatcher.group(1));

    topicBody = mainMatcher.group(2);

    topicResult.setBody(topicBody);
    return topicResult;
  }