예제 #1
0
        public async Task <JsonResult> HotProducts()
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                dynamic json = await HttpHelper.HttpGetJson("https://gw.api.alibaba.com/openapi/param2/2/portals.open/api.listHotProducts/78491?localCurrency=USD&language=en", false);

                json = json["result"]["products"];

                foreach (var item in json)
                {
                    try
                    {
                        string  img       = item["imageUrl"];
                        string  priceText = item["localPrice"].ToString().Replace("$", "").Replace("US", "");
                        decimal price     = decimal.Parse(priceText);
                        string  name      = item["productTitle"];
                        string  link      = "/Home/?Keywords=" + name;

                        UniversalItem uniItem = new UniversalItem()
                        {
                            Image = img, Name = name, Link = link, Price = price, PriceCoin = "USD", StoreName = ""
                        };
                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);

                        lst.Add(uniItem);
                    }
                    catch { }
                }
            }
            catch { }
            return(new JsonResult(lst));
        }
예제 #2
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string   BackupFile = (Environment.CurrentDirectory + "\\StaticData\\Geekbuy.xml");
                XElement doc        = XElement.Load(BackupFile);
                Log.ErrorMsg = "parse";

                dynamic data = JsonConvert.DeserializeObject(JsonConvert.SerializeXNode(doc));
                Log.ErrorMsg = "object";

                var items = data["feed"]["entry"];
                Log.ErrorMsg = "items";

                int bestMatch = 1000;
                foreach (var item in items)
                {
                    try
                    {
                        if (Watch.ElapsedMilliseconds / 1000.0 >= 5)
                        {
                            break;
                        }
                        string name = item["g:title"];
                        if (!name.ToLower().Contains(search.ToLower()))
                        {
                            continue;
                        }
                        decimal price = decimal.Parse(item["g:price"].ToString().Replace("USD", "").Trim());
                        if (minPrice > 0 && price < minPrice)
                        {
                            continue;
                        }
                        if (maxPrice > 0 && price > maxPrice)
                        {
                            continue;
                        }

                        string desc = item["g:description"];

                        string img = item["g:image_link"];


                        string link      = item["g:link"];
                        string affiliate = "415";
                        link = "https://affiliate.geekbuying.com/deeplink.php?affid=" + affiliate + "&url=" + link;
                        UniversalItem uniItem = new UniversalItem()
                        {
                            Image = img, Name = name, Link = link, Price = price, PriceCoin = "USD", StoreName = "GeekBuying", ItemRate = bestMatch, Description = desc
                        };

                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);
                        uniItem.Image             = uniItem.Image.Replace("https:", "http:");

                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError = true;

                        Log.ErrorMsg += " item: " + ex.Description();
                    }
                }
                if (minPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price >= minPrice).ToList();
                }
                if (maxPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price <= maxPrice).ToList();
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }


            return(lst);
        }
예제 #3
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string fields    = "longDescription,name,salePrice,largeImage,mediumImage,image,url,linkShareAffiliateUrl";
                string apiKey    = "GdzzX5e5C5oTrM1SXDD1kX1q";
                string affiliate = "puyUxqWIkNE";
                string request   = string.Format("https://api.bestbuy.com/v1/products(search={0})?format=json&show={1}&pageSize=100&page=1&apiKey={2}&LID={3}", search, fields, apiKey, affiliate);
                Log.ErrorMsg = "req";

                string jsonText = await HttpHelper.HttpGet(request, false);

                if (jsonText.IsEmpty())
                {
                    return(lst);
                }
                dynamic obj = null;
                Log.ErrorMsg = "parse";

                try
                {
                    obj = JsonConvert.DeserializeObject(jsonText);
                }
                catch { }
                if (obj == null)
                {
                    return(lst);
                }
                Log.ErrorMsg = "object";

                var items     = obj["products"];
                int bestMatch = 1000;
                Log.ErrorMsg = "items";

                foreach (var item in items)
                {
                    try
                    {
                        string img = item["largeImage"];
                        img = img.IsEmpty() ? item["mediumImage"] : img;
                        img = img.IsEmpty() ? item["image"] : img;


                        string        link          = item["url"];
                        string        linkAffiliate = item["linkShareAffiliateUrl"];
                        decimal       price         = decimal.Parse(item["salePrice"].ToString());
                        UniversalItem uniItem       = new UniversalItem()
                        {
                            Image = img, Name = item["name"], Link = linkAffiliate, Price = price, PriceCoin = "USD", StoreName = "BestBuy", ItemRate = bestMatch, Description = item["longDescription"]
                        };

                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);


                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError = true;

                        Log.ErrorMsg += "item: " + ex.Description();
                    }
                }
                if (minPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price >= minPrice).ToList();
                }
                if (maxPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price <= maxPrice).ToList();
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }

            return(lst);
        }
예제 #4
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string apiKey      = "33503";
                string fields      = "fields=productTitle,productUrl,imageUrl,salePrice,localPrice";
                string priceFilter = "";
                if (maxPrice > 0)
                {
                    priceFilter += "&originalPriceTo=" + maxPrice;
                }
                if (minPrice > 0)
                {
                    priceFilter += "&originalPriceFrom=" + minPrice;
                }
                Log.ErrorMsg = "request";
                string q = string.Format("http://gw.api.alibaba.com/openapi/param2/2/portals.open/api.listPromotionProduct/{0}?{1}&keywords={2}&pageNo={3}&pagSize=40&language=en&localCurrency=USD{4}", apiKey, fields, search, (offset + 1), priceFilter);
                Log.ErrorMsg = "parse";
                string jsonText = await HttpHelper.HttpGet(q, false);

                if (jsonText.IsEmpty())
                {
                    Log.ErrorMsg = "";
                    return(lst);
                }
                dynamic json = JsonConvert.DeserializeObject(jsonText);
                if (json == null)
                {
                    Log.ErrorMsg = "";
                    return(lst);
                }

                Log.ErrorMsg = "object";
                var items     = json["result"]["products"];
                int bestMatch = 1000;
                foreach (var item in items)
                {
                    try
                    {
                        Log.ErrorMsg = "item";
                        string  img       = item["imageUrl"];
                        string  link      = item["productUrl"];
                        string  priceText = item["localPrice"].ToString().Replace("$", "").Replace("US", "");
                        decimal price     = decimal.Parse(priceText);
                        string  name      = item["productTitle"];
                        try
                        {
                            name = System.Text.RegularExpressions.Regex.Replace(name, "<.*?>", String.Empty);
                        }
                        catch
                        {
                            HasError = true;

                            Log.ErrorMsg += " item name regular expression";
                        }
                        UniversalItem uniItem = new UniversalItem()
                        {
                            Image = img, Name = name, Link = link, Price = price, PriceCoin = "USD", StoreName = "Aliexpress", ItemRate = bestMatch
                        };

                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);


                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError      = true;
                        Log.ErrorMsg += " " + ex.Description();
                    }
                }
                if (minPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price >= minPrice).ToList();
                }
                if (maxPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price <= maxPrice).ToList();
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }

            return(lst);
        }
예제 #5
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                Log.ErrorMsg = "req";
                string request = string.Format("https://api.asos.com/product/search/v1/?q={0}&store=1&lang=en-GB&sizeschema=EU&currency=EUR&sort=freshness&channel=mobile-app&offset=0&limit=1000", search);
                request = await HttpHelper.HttpGet(request);

                Log.ErrorMsg = "parse";
                dynamic obj = JsonConvert.DeserializeObject(request);
                if (obj == null)
                {
                    return(lst);
                }
                Log.ErrorMsg = "object";
                var items     = obj["products"];
                int bestMatch = 1000;
                Log.ErrorMsg = "items";

                foreach (var item in items)
                {
                    try
                    {
                        string        img     = item["images"][0]["url"];
                        string        link    = "http://www.asos.com/" + item["url"];
                        decimal       price   = decimal.Parse(item["price"]["current"]["value"].ToString());
                        UniversalItem uniItem = new UniversalItem()
                        {
                            Image = img, Name = item["name"], Link = link, Price = price, PriceCoin = "EUR", StoreName = "Asos", ItemRate = bestMatch
                        };
                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);
                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError = true;

                        Log.ErrorMsg += "item: " + ex.Description();
                    }
                }
                if (minPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price >= minPrice).ToList();
                }
                if (maxPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price <= maxPrice).ToList();
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }


            return(lst);
        }
예제 #6
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string apikey  = "hg18hunjkx0ykt8wdfsmu54v";
                string request = "https://openapi.etsy.com/v2/listings/active?limit=25&includes=Images:1&api_key=" + apikey + "&keywords=" + search + "&offset=" + offset;
                Log.ErrorMsg = "req";

                string jsonStr = await HttpHelper.HttpGet(request);

                Log.ErrorMsg = "parse";

                dynamic json = (jsonStr).Replace("/**/(", "").Replace("\\", "").Replace(");", "");
                json = JsonConvert.DeserializeObject(json);
                int bestMatch = 1000;
                Log.ErrorMsg = "object";

                var items = json["results"];
                Log.ErrorMsg = "items";

                foreach (var item in items)
                {
                    try
                    {
                        string  name  = item["title"];
                        string  img   = item["Images"][0]["url_fullxfull"];
                        decimal price = decimal.Parse(item["price"].ToString());
                        string  coin  = item["currency_code"];
                        string  link  = item["url"];
                        string  desc  = name;
                        try
                        {
                            desc = item["description"];
                        }
                        catch { }
                        UniversalItem uniItem = new UniversalItem()
                        {
                            Description = desc, Name = name, Image = img, Price = price, PriceCoin = coin, Link = link, StoreName = "Etsy", ItemRate = bestMatch
                        };
                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);
                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError = true;

                        Log.ErrorMsg  = Log.ErrorMsg.IsEmpty() ? "" : Log.ErrorMsg;
                        Log.ErrorMsg += " item: " + ex.Description();
                    }
                }

                if (minPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price >= minPrice).ToList();
                }
                if (maxPrice > 0)
                {
                    lst = lst.Where(x => x.PriceWithCurrency["USD"].Price <= maxPrice).ToList();
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }

            return(lst);
        }
예제 #7
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string priceFilter = "";
                if (maxPrice > 0 && minPrice > 0)
                {
                    priceFilter = "&itemFilter(0).name=MaxPrice&itemFilter(0).value=" + maxPrice + "&itemFilter(1).name=MinPrice&itemFilter(1).value=" + minPrice;
                }
                else if (maxPrice > 0)
                {
                    priceFilter = "&itemFilter(0).name=MaxPrice&itemFilter(0).value=" + maxPrice;
                }
                else if (minPrice > 0)
                {
                    priceFilter = "&itemFilter(0).name=MinPrice&itemFilter(0).value=" + minPrice;
                }
                string affiliate = "&affiliate.trackingId=5338382419&affiliate.networkId=9";
                Log.ErrorMsg = "req";

                var ebayRes = await HttpHelper.HttpGet("http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SECURITY-APPNAME=barnuri-EasySear-PRD-659c57255-16fcb1b2&keywords=" + search + priceFilter + affiliate);

                Log.ErrorMsg = "parse";

                XDocument doc      = XDocument.Parse(ebayRes);
                string    jsonText = JsonConvert.SerializeXNode(doc);
                dynamic   obj      = JsonConvert.DeserializeObject(jsonText);
                if (obj == null)
                {
                    return(lst);
                }
                Log.ErrorMsg = "object";

                var items     = obj["findItemsByKeywordsResponse"]["searchResult"]["item"];
                int bestMatch = 1000;
                if (items == null)
                {
                    return(lst);
                }
                Log.ErrorMsg = "items";

                foreach (var item in items)
                {
                    try
                    {
                        string  name  = item["title"];
                        string  img   = item["galleryURL"];
                        decimal price = decimal.Parse(item["sellingStatus"]["currentPrice"]["#text"].ToString());
                        string  coin  = item["sellingStatus"]["currentPrice"]["@currencyId"];
                        string  link  = item["viewItemURL"];
                        string  desc  = "";
                        try
                        {
                            desc = name + " " + item["subtitle"];
                        }
                        catch { }
                        UniversalItem uniItem = new UniversalItem()
                        {
                            Description = desc, Name = name, Image = img, Price = price, PriceCoin = coin, Link = link, StoreName = "Ebay", ItemRate = bestMatch
                        };
                        uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);
                        lst.Add(uniItem);
                        bestMatch--;
                    }
                    catch (Exception ex)
                    {
                        HasError = true;

                        Log.ErrorMsg += "item: " + ex.Description();
                    }
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }

            return(lst);
        }
예제 #8
0
        public override async Task <List <UniversalItem> > Items(string search, decimal minPrice, decimal maxPrice, int offset = 0)
        {
            List <UniversalItem> lst = new List <UniversalItem>();

            try
            {
                string apikey      = "xs8shrr2bz2pw5e44fa7pme2";
                string priceFilter = "";
                if (maxPrice > 0 && minPrice > 0)
                {
                    priceFilter = "&facet.range=price:[ " + minPrice + " TO " + maxPrice + " ]";
                }
                else if (maxPrice > 0)
                {
                    priceFilter = "&facet.range=price:[ " + 0 + " TO " + maxPrice + " ]";
                }
                else if (minPrice > 0)
                {
                    priceFilter = "&facet.range=price:[ " + minPrice + " TO " + 99999 + " ]";
                }
                int    bestMatch = 1000;
                string affiliate = "&lsPublisherId=puyUxqWIkNE";
                string q         = "http://api.walmartlabs.com/v1/search?start=" + offset * 25 + 1 + "&numItems=25&apiKey=" + apikey + "&lsPublisherId=1&query=" + search + priceFilter + affiliate;
                Log.ErrorMsg = "req";
                q            = await HttpHelper.HttpGet(q, false);

                Log.ErrorMsg = "parse";
                dynamic res = JsonConvert.DeserializeObject(q);

                if (res != null)
                {
                    Log.ErrorMsg = "object";

                    dynamic items = res["items"];
                    Log.ErrorMsg = "items";

                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            try
                            {
                                decimal price = 0;
                                try
                                {
                                    price = decimal.Parse(item["salePrice"].ToString());
                                }
                                catch
                                {
                                    Log.ErrorMsg += " item error price parse";
                                }
                                string desc = item["shortDescription"];
                                string link = item["productUrl"];
                                //link = item["productTrackingUrl"];
                                UniversalItem uniItem = new UniversalItem()
                                {
                                    Description = desc, Name = item["name"], Image = item["largeImage"], Price = price, PriceCoin = "USD", ItemRate = bestMatch, Link = link, StoreName = "Walmart"
                                };
                                uniItem.PriceWithCurrency = StoresAPI.GeneratePriceWithCurrency(uniItem.Price, uniItem.PriceCoin);
                                lst.Add(uniItem);
                                bestMatch--;
                            }
                            catch (Exception ex)
                            {
                                HasError = true;

                                Log.ErrorMsg += " item: " + ex.Description();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HasError      = true;
                Log.ErrorMsg += " " + ex.Description();
            }

            return(lst);
        }