public void getTitle(Response response) { JXDocument doc = response.document(); try { logger.info( "url:{} {}", response.getUrl(), doc.sel("//h1[@class='postTitle']/a/text()|//a[@id='cb_post_title_url']/text()")); // do something } catch (Exception e) { e.printStackTrace(); } }
@Override public void start(Response response) { JXDocument doc = response.document(); try { List<Object> urls = doc.sel("//a[@class='titlelnk']/@href"); logger.info("{}", urls.size()); for (Object s : urls) { push(new Request(s.toString(), "getTitle")); } } catch (Exception e) { e.printStackTrace(); } }