313233343536373839
} } @Test public void testGetCrawlContentBySourceAndUrl() { Record record = controller.getCrawlContentBySourceAndUrl( "http://home.163.com/13/0119/10/8LJ06D77001048P8.html", sourceUrl); logger.info(ToStringBuilder.reflectionToString(record)); }
3738394041424344
recordDao.insertRecordList(list); } @Test public void testQueryRecordByUrl() { Record r = recordDao.queryRecordByUrl(record.getUrl()); logger.info(ToStringBuilder.reflectionToString(r)); }
434445464748495051
logger.info(ToStringBuilder.reflectionToString(r)); } @Test public void testUpdateContentById() { Record r = recordDao.queryRecordByUrl(record.getUrl()); r.setContent("after test"); recordDao.updateContentById(r.getId(), r.getContent()); }
145146147148149150151152153154155
replace.getReplacement()); } } String sourceId = source.getId().toString(); String title = document.title(); return new Record(title, url, recordContent, sourceId); } } EntityUtils.consume(entity); return null; } catch (Exception e) {
3233343536373839404142
public void run() { List<Record> records = new ArrayList<Record>(); List<String> links = crawlService.getLinkFromSource(source); for (String url : links) { Record record = crawlService.getContentFromLink(url, source); if (record != null) { records.add(record); } } recordDao.insertRecordList(records);
373839404142434445
} @Test public void testGetContentFromLink() { Source source = sourceDao.querySourceByUrl(URL); Record record = crawlService.getContentFromLink( "http://home.163.com/13/0123/18/8LU3QD5700104JVC.html", source); logger.info(ToStringBuilder.reflectionToString(record)); }