public void Execute(IJobExecutionContext context) { var jobUrl = context.JobDetail.JobDataMap.First(t => t.Key == "url").Value.ToString(); var jobRequestedOn = context.JobDetail.JobDataMap.First(t => t.Key == "requestedOn").Value.ToString(); var requestedElement = context.JobDetail.JobDataMap.First(t => t.Key == "requestedElement").Value.ToString(); var content = _webScrapeService.GetUrlContent(jobUrl); if (!string.IsNullOrEmpty(content)) { //get only requested element if specified if (!string.IsNullOrEmpty(requestedElement)) { content = _webScrapeService.GetFirstElementText(requestedElement, content); } _webScrapeService.StoreScrapeContent(content, jobRequestedOn, new Guid(context.JobDetail.Key.Name)); } }
public void GetUrlContent_HasContent_IfUrlIsValid() { var result = _webScrapeService.GetUrlContent("http://www.google.com"); Assert.IsFalse(string.IsNullOrEmpty(result)); }