Exemplo n.º 1
0
        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', ' ' }));
        }
Exemplo n.º 2
0
        private void addInfoToComp(Component comp, HtmlNode genInfo)
        {
            HtmlNode s1 = DOMUtils.getNextChildNodeWithClass(genInfo, "div", "advLineLevelContainer container");

            if (s1 == null)
            {
                return;
            }
            HtmlNode s2 = DOMUtils.getNextChildNodeWithClass(s1, "div", "col-xs-12 prodDescDivLL");

            if (s2 == null)
            {
                return;
            }
            HtmlNode s3 = DOMUtils.getNextChildNodeWithClass(s2, "div", "col-xs-10");

            if (s3 == null)
            {
                return;
            }
            HtmlNode s4 = DOMUtils.getNextChildNodeWithClass(s3, "div", "col-xs-12 keyDetailsDivLL");

            if (s4 == null)
            {
                return;
            }
            HtmlNode top = DOMUtils.getNextChildNodeWithClass(s4, "ul", "keyDetailsLL");

            if (top == null)
            {
                return;
            }
            HtmlNode provNum1 = DOMUtils.getNextChildNodeType(top, "li", 0);

            if (provNum1 == null)
            {
                return;
            }
            HtmlNode provNum2 = DOMUtils.getNextChildNodeWithClass(provNum1, "span", "keyValue");

            if (provNum2 == null)
            {
                return;
            }
            HtmlNode fabrNum1 = DOMUtils.getNextChildNodeType(top, "li", 1);

            if (fabrNum1 == null)
            {
                return;
            }
            HtmlNode fabrNum2 = DOMUtils.getNextChildNodeWithClass(fabrNum1, "span", "keyValue");

            if (fabrNum2 == null)
            {
                return;
            }
            HtmlNode fabr1 = DOMUtils.getNextChildNodeType(top, "li", 2);

            if (fabr1 == null)
            {
                return;
            }
            HtmlNode fabr2 = DOMUtils.getNextChildNodeWithClass(fabr1, "span", "keyValue");

            if (fabr2 == null)
            {
                return;
            }
            HtmlNode fabr3 = DOMUtils.getNextChildNodeType(fabr2, "a", 0);

            if (fabr3 == null)
            {
                return;
            }
            HtmlNode fabr4 = DOMUtils.getNextChildNodeType(fabr3, "span", 0);

            if (fabr4 == null)
            {
                return;
            }

            comp.VerderComponentNumber = provNum2.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });
            comp.ManufacturerNumber    = fabrNum2.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });
            comp.Manufacturer          = fabr4.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });
        }
Exemplo n.º 3
0
        private void addInfoToComp(Component comp, HtmlDocument dom)
        {
            HtmlNode pn = dom.GetElementbyId("reportPartNumber");

            if (pn == null)
            {
                return;
            }
            comp.VerderComponentNumber = pn.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });

            HtmlNode top = dom.GetElementbyId("product-overview");

            if (top == null)
            {
                return;
            }
            HtmlNode s1 = DOMUtils.getNextChildNodeType(top, "tbody", 0);

            if (s1 == null)
            {
                s1 = top;
            }

            foreach (HtmlNode hn in s1.ChildNodes)
            {
                if (hn.Name.Equals("tr"))
                {
                    HtmlNode td = DOMUtils.getNextChildNodeType(hn, "td", 0);
                    if (td == null)
                    {
                        continue;
                    }
                    HtmlNode h1 = DOMUtils.getNextChildNodeType(td, "h1", 0);
                    if (h1 != null)
                    {
                        comp.ManufacturerNumber = h1.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });
                        continue;
                    }
                    HtmlNode h2 = DOMUtils.getNextChildNodeType(td, "h2", 0);
                    if (h2 != null)
                    {
                        HtmlNode span1 = DOMUtils.getNextChildNodeType(h2, "span", 0);
                        if (span1 == null)
                        {
                            continue;
                        }
                        HtmlNode span2 = DOMUtils.getNextChildNodeType(span1, "span", 0);
                        if (span2 == null)
                        {
                            continue;
                        }
                        comp.Manufacturer = span2.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' });
                        continue;
                    }
                }
            }

            comp.PriceString = "";
            HtmlNode pricedoc = dom.GetElementbyId("priceProcurement");

            if (pricedoc == null)
            {
                return;
            }
            HtmlNode p0 = DOMUtils.getNextChildNodeWithClass(pricedoc, "div", "catalog-pricing");

            if (p0 == null)
            {
                return;
            }
            HtmlNode p1 = DOMUtils.getNextChildNodeWithClass(p0, "table", "product-dollars");

            if (p1 == null)
            {
                return;
            }
            HtmlNode p2 = DOMUtils.getNextChildNodeType(p1, "tbody", 0);

            if (p2 == null)
            {
                p2 = p1;
            }
            foreach (HtmlNode hn in p2.ChildNodes)
            {
                if (hn.Name.Equals("tr"))
                {
                    HtmlNode amt = DOMUtils.getNextChildNodeType(hn, "td", 0);
                    if (amt == null)
                    {
                        continue;
                    }
                    HtmlNode upr = DOMUtils.getNextChildNodeType(hn, "td", 1);
                    if (upr == null)
                    {
                        continue;
                    }
                    HtmlNode upr2 = DOMUtils.getNextChildNodeType(hn, "span", 0);
                    if (upr2 != null)
                    {
                        upr = upr2;
                    }

                    try
                    {
                        String   amo = amt.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' }).Replace(".", "");
                        String[] pri = upr.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' }).Split(' ');

                        int    am = int.Parse(amo);
                        double pr = double.Parse(pri[pri.Length - 1]);

                        CompPrice cp = new CompPrice();
                        cp.Amount = am;
                        cp.Price  = pr;
                        comp.Prices.Add(cp);
                    }
                    catch (Exception e) { }
                }
            }
        }
Exemplo n.º 4
0
        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', ' ' }));
        }