Beispiel #1
0
 public String GetLocation(HtmlNode node)
 {
     return(TextExtractorEbayCom.ExtractEbayComLocation(node.SelectSingleNode("descendant::span[contains(@class,'s-item__location s-item__itemLocation')]").InnerText));
 }
Beispiel #2
0
 public DateTime GetTime(HtmlNode node)
 {
     return(TextExtractorEbayCom.ExtractEbayComTimeLeft(node.OuterHtml, DateTime.Now));
 }
Beispiel #3
0
        //create ebayitems and returns url to next page
        public override List <EbayItem> CreateItems(String filename)
        {
            HtmlDocument doc  = new HtmlDocument();
            var          path = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.GetType().Name), filename);

            doc.Load(path, Encoding.UTF8);
            EbayItem        ei;
            List <EbayItem> list = new List <EbayItem>();

            foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//li[@class='s-item  ']"))
            {
                try
                {
                    String itemlink = GetItemLink(node);
                    String itemid   = TextExtractorEbayCom.ExtractItemIdFromUrl(itemlink);
                    String piclink  = GetImageLink(node);
                    String title    = GetTitle(node);

                    int followers = GetFollowers(node);

                    String location = "";
                    if (node.InnerHtml.Contains("From"))
                    {
                        location = GetLocation(node);
                    }

                    DateTime clock = DateTime.Now;
                    if (node.InnerHtml.Contains("Time left"))
                    {
                        foreach (HtmlNode n in node.SelectNodes("descendant::span[contains(@class,'s-item__time-left')]"))
                        {
                            clock = TextExtractorEbayCom.ExtractEbayComTimeLeft(n.OuterHtml, DateTime.Now);
                        }
                    }
                    double exchange = Double.Parse(Properties.Resources.europerdollar);

                    string price      = node.SelectSingleNode("descendant::span[contains(@class,'s-item__price')]").InnerText;
                    double startPrice = exchange * Double.Parse(TextExtractorEbayCom.ExtractEbayComStartPrice(price));
                    double endPrice   = exchange * Double.Parse(TextExtractorEbayCom.ExtractEbayComEndPrice(price));
                    double shipping   = 0;
                    if (node.InnerHtml.Contains("shipping"))
                    {
                        shipping = exchange * TextExtractorEbayCom.ExtractShipping(node.SelectSingleNode("descendant::span[contains(@class,'s-item__shipping s-item__logisticsCost')]").InnerText);
                    }

                    if (startPrice > 0)
                    {
                        ei = new EbayItem(startPrice, endPrice, title, itemlink, itemid, clock, followers, shipping, location, piclink);
                        list.Add(ei);
                        Console.Write("+");
                    }
                    else
                    {
                        ei = new EbayItem(startPrice, endPrice, title, itemlink, itemid, clock, followers, shipping, location, piclink);
                        list.Add(ei);
                        Console.WriteLine("==================================================\n" + ei);
                    }
                }
                catch (Exception e)
                {
                    CsvController.CreateDocument(list, filename + ".csv");
                    Console.WriteLine("Problem with creating Ebayitem, check " + filename + ".csv");
                    Console.WriteLine(e.Message);
                }
            }

            return(list);
        }
Beispiel #4
0
 public String GetImageLink(HtmlNode node)
 {
     return(TextExtractorEbayCom.ExtractPicUrl(node.InnerHtml));
 }
Beispiel #5
0
 public int GetFollowers(HtmlNode node)
 {
     return(TextExtractorEbayCom.ExtractFollowersEbayCom(node.InnerHtml));
 }
Beispiel #6
0
        //create ebayitems
        public override List <EbayItem> CreateItems(String filename)
        {
            HtmlDocument doc  = new HtmlDocument();
            var          path = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.GetType().Name), filename);

            doc.Load(path, Encoding.UTF8);
            EbayItem        ei;
            List <EbayItem> list = new List <EbayItem>();

            foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//li[@class='sresult lvresult clearfix li' or @class='sresult lvresult clearfix li shic']"))
            {
                try
                {
                    //Console.WriteLine("#########");
                    string itemid   = node.Attributes["id"].Value;
                    string itemlink = node.SelectSingleNode(".//h3[@class='lvtitle']").SelectSingleNode("a").Attributes["href"].Value;
                    string piclink  = node.SelectSingleNode(".//div[@class='lvpicinner full-width picW']").SelectSingleNode(".//img").Attributes["src"].Value;

                    //check once if there exists a better picurl , 2nd condition makes sure there even is an imageurl
                    if (piclink.Contains(".gif") && node.SelectSingleNode(".//div[@class='lvpicinner full-width picW']").SelectSingleNode(".//img").Attributes["imgurl"] != null)
                    {
                        piclink = node.SelectSingleNode(".//div[@class='lvpicinner full-width picW']").SelectSingleNode(".//img").Attributes["imgurl"].Value;
                    }
                    //Console.WriteLine(itemid+"\n"+itemlink+"\n"+piclink);
                    string title     = TextExtractorEbayCoUk.ExtractTitle(node.SelectSingleNode(".//h3[@class='lvtitle']").SelectSingleNode("a").Attributes["title"].Value);
                    int    followers = int.Parse(TextExtractorEbayCoUk.ExtractFollowers(node.SelectSingleNode(".//li[@class='lvextras']").InnerText.TrimEnd().TrimStart()));
                    string location  = "";
                    if (null != node.SelectSingleNode(".//ul[@class='lvdetails left space-zero full-width']"))
                    {
                        location = TextExtractorEbayCoUk.ExtractLocation(node.SelectSingleNode(".//ul[@class='lvdetails left space-zero full-width']").InnerHtml);
                    }

                    else
                    {
                        location = null;
                    }
                    //Console.WriteLine(title + "\n" + followers + "\n" + location);
                    string timeleft = null;
                    if (null != node.SelectSingleNode(".//span[@class='tme']"))
                    {
                        timeleft = TextExtractorEbayCom.ExtractTime(node.SelectSingleNode(".//span[@class='tme']").InnerHtml);
                    }
                    DateTime clock = GetEnddate(timeleft);

                    double exchange = Double.Parse(Properties.Resources.europerpound);

                    string price = node.SelectSingleNode(".//li[@class='lvprice prc']").InnerText.TrimStart().TrimEnd();
                    //Console.WriteLine("====="+price);
                    double startPrice = exchange * Double.Parse(TextExtractorEbayCoUk.ExtractEbayCoUkStartPrice(price));

                    double endPrice = exchange * Double.Parse(TextExtractorEbayCoUk.ExtractEbayCoUkEndPrice(price));
                    //Console.WriteLine(clock+"\n"+ startPrice + "\n" + endPrice + "\n");
                    double shipping;
                    if (null != node.SelectSingleNode("//span[@class='ship']"))
                    {
                        shipping = exchange * Double.Parse(TextExtractorEbayCoUk.ExtractShippingEbayCoUk(node.SelectSingleNode(".//span[@class='ship']").InnerText));
                    }
                    else
                    {
                        shipping = 0;
                    }

                    if (startPrice > 0)
                    {
                        ei = new EbayItem(startPrice, endPrice, title, itemlink, itemid, clock, followers, shipping, location, piclink);
                        list.Add(ei);
                        Console.Write("+");
                    }
                    else
                    {
                        ei = new EbayItem(startPrice, endPrice, title, itemlink, itemid, clock, followers, shipping, location, piclink);
                        list.Add(ei);
                        Console.Write("+");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Problem with creating Ebayitem");
                    Console.WriteLine(e.Message);
                }
            }
            return(list);
        }