- StringBuilder sb = new StringBuilder();
- try {
- response = getClient().execute(request);
- Pattern startPattern = Pattern.compile(startMatch);
- Pattern endPattern = Pattern.compile(endMatch);
- try (BufferedReader br = new BufferedReader(
- new InputStreamReader(
- response.getEntity().getContent(),
- ChessHogScannerConstants.CHARSET
- )
- )) {
- String line;
- boolean isMatch = false;
- while ((line = br.readLine()) != null) {
- Matcher matcher = isMatch
- ? endPattern.matcher(line)
- : startPattern.matcher(line);
- if (matcher.find()) {
- sb.append(line);
- if (isMatch && isFirst) {
- break;
- }
- isMatch = !isMatch;
- } else {
- if (isMatch) {
- sb.append(line);
- }
- }
- }
- }
- } catch (IOException cause) {
- throw new ChessHogScannerException(
- String.format("Error occurred for requesting URL: %s", url), cause
- );
- } finally {
- if (response != null) {
- try {
- response.close();
- } catch (IOException ignored) {}
- }
- }
- return sb.length() > 0 ? sb.toString() : null;
- }
-*/
-
- protected RegexResult matchRequest(String url, RegexMatcher matcher) throws ChessHogScannerException {
- HttpGet request = new HttpGet(url);
- CloseableHttpResponse response = null;