public Shop(string name, WebScraper refScraper) { switch (name.ToLower()) { case "audiosolutions": _shop = new ShopAudioSolutions(refScraper); break; case "baxmusic": _shop = new ShopBaxMusic(refScraper); break; case "energyson": _shop = new ShopEnergySon(refScraper); break; case "keymusic": _shop = new ShopKeyMusic(refScraper); break; case "kitary": _shop = new ShopKitary(refScraper); break; case "michenaud": _shop = new ShopMichenaud(refScraper); break; case "musicmatos": _shop = new ShopMusicMatos(refScraper); break; case "musicstore": _shop = new ShopMusicStore(refScraper); break; case "starsmusic": _shop = new ShopStarsMusic(refScraper); break; case "thomann": _shop = new ShopThomann(refScraper); break; case "universsons": _shop = new ShopUniversSons(refScraper); break; case "woodbrass": _shop = new ShopWoodbrass(refScraper); break; case "centrechopin": _shop = new ShopCentreChopin(refScraper); break; default: break; } }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { try { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("li.ajax_block_product"); foreach (var node in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode modelNode in node.CssSelect("a.product-name")) { m = modelNode.GetAttributeValue("title"); WebScraper.ExtractBrandFromModel(manufacturer, ref m, ref brand); } foreach (HtmlNode hrefNode in node.CssSelect("a.quick-view")) { murl = hrefNode.GetAttributeValue("href"); } foreach (HtmlNode priceNode in node.CssSelect("span.product-price")) { price = priceNode.InnerHtml; price = price.Trim().Replace("\u202F", "").Replace(",", "."); price = price.Replace(".00", ""); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } } catch (Exception ex) { m_refScraper.ThrowException(ShopName, ex.Message); } return(true); }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("div.fx-product-list-entry"); foreach (var node in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode brandNode in node.CssSelect("span.title__manufacturer")) { brand = WebScraper.UppercaseFirst(brandNode.InnerHtml); } foreach (HtmlNode modelNode in node.CssSelect("span.title__name")) { m = modelNode.InnerHtml; } foreach (HtmlNode priceNode in node.CssSelect("span.fx-typography-price-primary")) { price = priceNode.InnerHtml; price = price.Trim().Replace(".", ""); } foreach (HtmlNode urlNode in node.CssSelect("a.product__content")) { murl = urlNode.GetAttributeValue("href"); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("div.products-grid-item"); foreach (var productNode in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode infoNode in productNode.CssSelect(".pdt_brand")) { brand = WebScraper.UppercaseFirst(infoNode.InnerHtml.Trim()); } foreach (HtmlNode urlNode in productNode.CssSelect("a.title")) { murl = "https://www.stars-music.fr" + urlNode.GetAttributeValue("href"); } foreach (HtmlNode nameNode in productNode.CssSelect(".pdt_name")) { m = WebScraper.UppercaseFirst(nameNode.InnerText.Trim()); } foreach (HtmlNode priceNode in productNode.CssSelect("div.price")) { price = HttpUtility.HtmlDecode(priceNode.InnerHtml).Trim(); price = price.Replace(".00", ""); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
public static void ExtractBrandFromModel(string manufacturer, ref string model, ref string brand) { string t1 = model.ToLower(); String searchBrand = manufacturer.Replace('+', ' '); string t2 = t1.Replace(searchBrand.ToLower(), ""); if (t2.Length < t1.Length) { model = model.Substring(t1.Length - t2.Length).Trim(); brand = WebScraper.UppercaseFirst(searchBrand.ToLower()); } }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNode = root.CssSelect(".product-box"); foreach (var node in productNode) { string enc = node.GetAttributeValue("data-product"); string info = HttpUtility.HtmlDecode(enc); var productInfo = JsonConvert.DeserializeObject <dynamic>(info); string brand = productInfo.brand; string murl = url; string m = productInfo.name; string price = productInfo.price; price = price.Replace(".00", ""); string currency = CurrencyTools.GetCurrencySymbol((string)productInfo.currencyCode); WebScraper.ExtractBrandFromModel(manufacturer, ref m, ref brand); foreach (HtmlNode urlNode in node.CssSelect("div.product-thumb > a")) { murl = "https://www.bax-shop.fr" + urlNode.GetAttributeValue("href"); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price + " " + currency); } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
public ShopAudioSolutions(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopMichenaud(WebScraper refScraper) { m_refScraper = refScraper; }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { try { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; bool bFound = false; // Search result page var productNodes = root.CssSelect("div.slider-boxes > a"); foreach (var productNode in productNodes) { bFound = true; string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; murl = "https://www.woodbrass.com/" + productNode.GetAttributeValue("href"); string info = productNode.GetAttributeValue("onclick"); var data = info.Split(','); m = WebScraper.UppercaseFirst(getValue(data[2])); price = getValue(HttpUtility.HtmlDecode(data[4])); price = price.Replace(".00", ""); price += " €"; brand = WebScraper.UppercaseFirst(getValue(HttpUtility.HtmlDecode(data[5]))); bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, "Woodbrass", murl, price); } } if (!bFound) { productNodes = root.CssSelect("script"); if (productNodes.Count() > 0) { // Product page string redirect = productNodes.Last().InnerHtml; var data = redirect.Split('\''); url = "https://www.woodbrass.com/" + data[1]; response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { html = await response.Content.ReadAsStringAsync(); doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); root = doc.DocumentNode; string price = string.Empty; string m = string.Empty; string brand = string.Empty; var modelNodes = root.CssSelect("h1"); if (modelNodes.Count() > 0) { m = WebScraper.UppercaseFirst(modelNodes.First().InnerHtml); } var priceNodes = root.CssSelect("div.clrBleu"); if (priceNodes.Count() > 0) { price = priceNodes.First().InnerHtml; price = price.Replace(".00", ""); price = price.Insert(price.Length - 1, " "); } var metaNodes = root.CssSelect("meta"); foreach (var metaNode in metaNodes) { if (metaNode.GetAttributeValue("itemprop") == "brand") { brand = WebScraper.UppercaseFirst(metaNode.GetAttributeValue("content")); break; } } m_refScraper.AddPrice(brand, m, "Woodbrass", url, price); } } } } } catch (Exception e) { Console.WriteLine(e); } return(true); }
public ShopKitary(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopUniversSons(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopWoodbrass(WebScraper refScraper) { m_refScraper = refScraper; }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("div.search_product_item"); foreach (var productNode in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode urlNode in productNode.CssSelect("a")) { murl = "https://www.energyson.fr/" + urlNode.GetAttributeValue("href"); } foreach (HtmlNode nameNode in productNode.CssSelect("div.name")) { m = WebScraper.UppercaseFirst(nameNode.InnerHtml.Trim()); brand = m.Split().FirstOrDefault(); if (String.IsNullOrEmpty(brand)) { brand = string.Empty; } } foreach (HtmlNode priceNode in productNode.CssSelect("div.price")) { price = HttpUtility.HtmlDecode(priceNode.InnerHtml).Trim(); price = price.Replace(",00", ""); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } if (productNodes.Count() == 0) { productNodes = root.CssSelect("#product_zoom"); if (productNodes.Count() == 1) { // Direct to product page string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; var urlNode = root.CssSelect("div.fb-share-button"); if (urlNode.Count() == 1) { murl = urlNode.First().GetAttributeValue("data-href"); } foreach (HtmlNode dataNode in productNodes.CssSelect("h1")) { brand = dataNode.ChildNodes.First().InnerText; m = dataNode.ChildNodes.Last().InnerText; } foreach (HtmlNode priceNode in productNodes.CssSelect("span.product_zoom_price_vente > span")) { price = HttpUtility.HtmlDecode(priceNode.InnerText).Trim(); price = price.Replace(",00", ""); break; } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("div.tile-product"); foreach (var productNode in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode urlNode in productNode.CssSelect("a.kor-product-link")) { murl = urlNode.GetAttributeValue("href"); m = urlNode.InnerText.Trim(); WebScraper.ExtractBrandFromModel(manufacturer, ref m, ref brand); } foreach (HtmlNode priceNode in productNode.CssSelect("span.kor-product-sale-price-value")) { price = HttpUtility.HtmlDecode(priceNode.InnerHtml).Trim(); price = price.Replace(",00", ""); price = price.Replace(".", ""); price = price.Replace(",", "."); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, "Music Store", murl, price); } } if (productNodes.Count() == 0) { productNodes = root.CssSelect("div.productdata"); if (productNodes.Count() == 1) { // Direct to product page string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; var urlNode = root.CssSelect("input#RedirectURL"); if (urlNode.Count() == 1) { murl = urlNode.First().GetAttributeValue("value"); } foreach (HtmlNode dataNode in productNodes.CssSelect("h1")) { brand = dataNode.ChildNodes.First().InnerText; m = dataNode.ChildNodes.Last().InnerText; } foreach (HtmlNode priceNode in productNodes.CssSelect("span.kor-product-sale-price-value")) { price = HttpUtility.HtmlDecode(priceNode.InnerHtml).Trim(); price = price.Replace(",00", ""); price = price.Replace(".", ""); price = price.Replace(",", "."); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
public ShopStarsMusic(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopEnergySon(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopBaxMusic(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopThomann(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopCentreChopin(WebScraper refScraper) { m_refScraper = refScraper; }
private async Task <bool> Search(string url, string manufacturer, string model, bool strictSearch) { CultureInfo culture = new CultureInfo("fr-FR", false); var response = await m_refScraper.Analyze(new Uri(url)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var html = await response.Content.ReadAsStringAsync(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var root = doc.DocumentNode; var productNodes = root.CssSelect("div.grilleItem"); foreach (var productNode in productNodes) { string m = string.Empty; string price = string.Empty; string murl = string.Empty; string brand = string.Empty; foreach (HtmlNode name in productNode.CssSelect("a.grilleLink")) { murl = name.GetAttributeValue("href"); } foreach (HtmlNode name in productNode.CssSelect("span.articleMarque")) { brand = WebScraper.UppercaseFirst(HttpUtility.HtmlDecode(name.InnerHtml)); } foreach (HtmlNode name in productNode.CssSelect("div.grilleDes")) { m = WebScraper.UppercaseFirst(HttpUtility.HtmlDecode(name.InnerHtml)).Trim(); int pos = m.IndexOf("</span>"); if (pos != -1) { m = WebScraper.UppercaseFirst(m.Substring(pos + 8)).Trim(); } } foreach (HtmlNode priceNode in productNode.CssSelect("span.price")) { price = HttpUtility.HtmlDecode(priceNode.InnerHtml).Trim(); price = price.Replace(".00", ""); price = price.Insert(price.Length - 1, " "); } bool canAdd = culture.CompareInfo.IndexOf(m, model, CompareOptions.IgnoreCase) >= 0; if (strictSearch) { canAdd &= culture.CompareInfo.IndexOf(brand, manufacturer, CompareOptions.IgnoreCase) >= 0; } if (canAdd) { m_refScraper.AddPrice(brand, m, ShopName, murl, price); } } } else { m_refScraper.ThrowException(ShopName, response.ReasonPhrase); } return(true); }
public ShopKeyMusic(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopMusicMatos(WebScraper refScraper) { m_refScraper = refScraper; }
public ShopMusicStore(WebScraper refScraper) { m_refScraper = refScraper; }