//build query private string BuildSearchRequestBody(ClothesQuery query) { StringBuilder contentBuilder = new StringBuilder(); string searchGender = (query.SearchGender ?? string.Empty); string searchClothing = (query.SearchClothing ?? string.Empty); if (searchClothing.Contains("dresses")) { contentBuilder.Append(searchGender); contentBuilder.Append("/"); contentBuilder.Append(searchClothing); contentBuilder.Append("/cat/?cid=8799"); } else if (searchClothing.Contains("skirts")) { contentBuilder.Append(searchGender); contentBuilder.Append("/"); contentBuilder.Append(searchClothing); contentBuilder.Append("/cat/?cid=2639"); } return(contentBuilder.ToString()); }
//send to website (through web client) //send to parser private async Task <Clothes[]> GetResults(ClothesQuery query) { string content = BuildSearchRequestBody(query); WebResponse response = await _webClient.Post(_baseUrl, content); CheckIfReponseIsSuccessful(response); return(await _searchResultsParser.Parse(response.Content)); }
public async Task <Clothes[]> CrawlSearchResults(ClothesQuery query) { if (query != null) { return(await GetResults(query)); } return(new Clothes[0]); }
//run engine protected async Task <Clothes[]> RunCrawling(ClothesQuery query) { Clothes[] foundClothes = await _asosEngine.CrawlSearchResults(query); if (!foundClothes?.Any() ?? true) { return(new Clothes[0]); } return(foundClothes); }
private string BuildSearchRequestBody(ClothesQuery query) { StringBuilder contentBuilder = new StringBuilder(); string searchGender = (query.SearchGender ?? string.Empty); string searchClothing = (query.SearchClothing ?? string.Empty); contentBuilder.Append(searchGender); contentBuilder.Append("/"); contentBuilder.Append(searchClothing); return(contentBuilder.ToString()); }