@Test public void shouldParseOtherResultsCorrectly() throws Exception { String html = Resources.toString(Resources.getResource(BinsearchTest.class, "/org/nzbhydra/mapping/binsearch_randm.html"), Charsets.UTF_8); List<SearchResultItem> searchResultItems = testee.getSearchResultItems(html, new SearchRequest()); assertThat(searchResultItems.size(), is(41)); }
@SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; } }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  @Override NfoResult getNfo(String guid); }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  @Override NfoResult getNfo(String guid);  }