public override string getComponentNumberFromLink(string link) { String[] part = link.Split('/'); if (part.Length < 4) { return(null); } if (!part[2].Contains("digikey")) { return(null); } HtmlAgilityPack.HtmlDocument dom = DOMUtils.getDOMFromLink(link, "text/html"); HtmlNode someNode = dom.GetElementbyId("reportPartNumber"); if (someNode == null) { HtmlNode c1 = dom.GetElementbyId("product-overview"); if (c1 == null) { return(null); } HtmlNode c2 = DOMUtils.getNextChildNodeType(c1, "tbody", 0); if (c2 == null) { c2 = c1; } HtmlNode c3 = DOMUtils.getNextChildNodeType(c2, "tr", 0); if (c3 == null) { return(null); } HtmlNode c4 = DOMUtils.getNextChildNodeType(c3, "td", 0); if (c4 == null) { return(null); } someNode = DOMUtils.getNextChildNodeType(c4, "meta", 0); if (someNode == null) { return(null); } } return(someNode.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' })); }
public override Component getComponentFromNumber(string number) { Component comp = Component.getFromVenderNumber(VenderName, number); bool excists = false; if (comp != null) { if (comp.CheckedAt.AddDays(1).CompareTo(DateTime.Now) > 0) { return(comp); } excists = true; } if (!excists) { comp = new Component(); } HtmlDocument dom = DOMUtils.getDOMFromLink("https://www.digikey.be/products/nl?keywords=" + number, "text/html"); addInfoToComp(comp, dom); comp.Vendername = VenderName; comp.Name = number; comp.Link = "https://www.digikey.be/products/nl?keywords=" + number; comp.CheckedAt = DateTime.Now; if (excists) { Component.update(comp); } else { Component.add(comp); } return(comp); }
public override string getComponentNumberFromLink(string link) { String[] part = link.Split('/'); if (part.Length < 4) { return(null); } if (!part[2].Contains("mouser")) { return(null); } HtmlAgilityPack.HtmlDocument dom = DOMUtils.getDOMFromLink(link, null); HtmlNode someNode = dom.GetElementbyId("spnMouserPartNumFormattedForProdInfo"); if (someNode == null) { return(null); } return(someNode.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' })); }
public override Component getComponentFromNumber(string number) { Component comp = Component.getFromVenderNumber(VenderName, number); bool excists = false; if (comp != null) { if (comp.CheckedAt.AddDays(1).CompareTo(DateTime.Now) > 0) { return(comp); } excists = true; } if (!excists) { comp = new Component(); } HtmlDocument dom = DOMUtils.getDOMFromLink("https://benl.rs-online.com/web/c/?sra=oss&r=t&searchTerm=" + number); HtmlNode prices = dom.GetElementbyId("break-prices-list"); HtmlNode genInfo = dom.GetElementbyId("pagecell"); if (prices == null || genInfo == null) { return(null); } comp.PriceString = ""; foreach (HtmlNode p in prices.ChildNodes) { String amount = null; String price = null; if (p.ChildNodes.Count > 2) { foreach (HtmlNode cn in p.ChildNodes) { String classValue = null; foreach (HtmlAttribute a in cn.Attributes) { if (a.Name.Equals("class")) { classValue = a.Value; } } if (classValue != null) { if (classValue.StartsWith("breakRange")) { amount = cn.InnerHtml; } else if (classValue.StartsWith("unitPrice")) { price = cn.InnerHtml; } } } } if (amount != null && price != null) { try { String[] amo = amount.Trim(new char[] { '\r', '\t', '\n', ' ' }).Split(' '); String[] pri = price.Trim(new char[] { '\r', '\t', '\n', ' ' }).Split(' '); int am = int.Parse(amo[0]); double pr = double.Parse(pri[0]); CompPrice cp = new CompPrice(); cp.Amount = am; cp.Price = pr; comp.Prices.Add(cp); } catch (Exception e) {} } } addInfoToComp(comp, genInfo); comp.Link = "https://benl.rs-online.com/web/c/?sra=oss&r=t&searchTerm=" + number; comp.Name = number; comp.Vendername = VenderName; comp.CheckedAt = DateTime.Now; if (excists) { Component.update(comp); } else { Component.add(comp); } return(comp); }
public override string getComponentNumberFromLink(string link) { String[] part = link.Split('/'); if (part.Length < 4) { return(null); } if (!part[2].Contains("rs-online")) { return(null); } HtmlDocument dom = DOMUtils.getDOMFromLink(link); HtmlNode genInfo = dom.GetElementbyId("pagecell"); if (genInfo == null) { return(null); } HtmlNode s1 = DOMUtils.getNextChildNodeWithClass(genInfo, "div", "advLineLevelContainer container"); if (s1 == null) { return(null); } HtmlNode s2 = DOMUtils.getNextChildNodeWithClass(s1, "div", "col-xs-12 prodDescDivLL"); if (s2 == null) { return(null); } HtmlNode s3 = DOMUtils.getNextChildNodeWithClass(s2, "div", "col-xs-10"); if (s3 == null) { return(null); } HtmlNode s4 = DOMUtils.getNextChildNodeWithClass(s3, "div", "col-xs-12 keyDetailsDivLL"); if (s4 == null) { return(null); } HtmlNode top = DOMUtils.getNextChildNodeWithClass(s4, "ul", "keyDetailsLL"); if (top == null) { return(null); } HtmlNode provNum1 = DOMUtils.getNextChildNodeType(top, "li", 0); if (provNum1 == null) { return(null); } HtmlNode provNum2 = DOMUtils.getNextChildNodeWithClass(provNum1, "span", "keyValue"); if (provNum2 == null) { return(null); } return(provNum2.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' })); }