public override ProductDetails GetProductDetails(string productUrl, CancellationToken token) { HtmlDocument doc = new HtmlDocument(); var client = ClientFactory.GetProxiedFirefoxClient(); var response = CfBypasser.GetRequestedPage(client, this, productUrl, token); doc.LoadHtml(response.Content.ReadAsStringAsync().Result); var root = doc.DocumentNode; var sizeNodes = root.SelectNodes("//*[contains(@class,'styled-radio')]/label"); var sizes = sizeNodes.Select(node => node.InnerText).ToList(); var name = root.SelectSingleNode("//*[contains(@class, 'prod-title')]").InnerText.Trim(); var priceNode = root.SelectSingleNode("//div[contains(@class, 'price')]/span/strong"); var price = Utils.ParsePrice(priceNode.InnerText); var image = root.SelectSingleNode("//*[@id='image-0']").GetAttributeValue("src", null); ProductDetails result = new ProductDetails() { Price = price.Value, Name = name, Currency = price.Currency, ImageUrl = image, Url = productUrl, Id = productUrl, ScrapedBy = this }; foreach (var size in sizes) { result.AddSize(size, "Unknown"); } return(result); }
private void FindItemsInternal(List <Product> listOfProducts, SearchSettingsBase settings, CancellationToken token, string url) { HtmlDocument document = new HtmlDocument(); var client = ClientFactory.GetProxiedFirefoxClient(); var response = CfBypasser.GetRequestedPage(client, this, url, token); document.LoadHtml(response.Content.ReadAsStringAsync().Result); if (document == null) { Logger.Instance.WriteErrorLog($"Can't Connect to off---white"); throw new WebException("Can't connect to website"); } var node = document.DocumentNode; var container = node.SelectSingleNode("//section[@class='products']"); if (container == null) { Logger.Instance.WriteErrorLog("Unexpected Html!!"); Logger.Instance.SaveHtmlSnapshop(document); throw new WebException("Unexpected Html"); } var items = container.SelectNodes("./article"); foreach (var item in items) { token.ThrowIfCancellationRequested(); #if DEBUG LoadSingleProduct(listOfProducts, settings, item); #else LoadSingleProductTryCatchWraper(listOfProducts, settings, item); #endif } }