Esempio n. 1
0
        private void ValidateUrl(UrlFindModel urlFindModel)
        {
            var regex = new Regex(@"/^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/");

            if (!urlFindModel.Url.StartsWith("https://") || !urlFindModel.Url.StartsWith("http://"))
            {
                urlFindModel.Url = "https://" + urlFindModel.Url;
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> GetUrls(UrlFindModel urlFindModel)
        {
            var urls = await _urlFinder.FindUrls(urlFindModel);

            if (!urls.Any())
            {
                return(View("OperationError", new OperationErrorModel
                {
                    Message = "Не удалось найти ссылки"
                }));
            }

            _domainService.SaveUrls(urls);
            return(View("ResultView", urls));
        }
Esempio n. 3
0
        public async Task <List <UrlModel> > FindUrls(UrlFindModel urlFindModel)
        {
            if (urlFindModel.DepthLimit < 0 || urlFindModel.UrlsLimit < 0)
            {
                return(new List <UrlModel>());
            }

            _hostUrl = urlFindModel.Url;
            var urls = await GetUrls(urlFindModel.Url, urlFindModel.UrlsLimit);

            _existedUrls.AddRange(urls.Select(x => x.Url).Distinct());

            urls.AddRange(await GetReferencedUrls(urls, urlFindModel.DepthLimit, urlFindModel.UrlsLimit));

            return(urls);
        }