Beispiel #1
0
        private static bool indexHMPage(CrawledPage pageToIndex, ref ClothingItem item)
        {
            var indexer = new HmIndexer(pageToIndex);

            if (indexer.getTitle() && indexer.getPrice() && indexer.getImage() && indexer.getDescription() && indexer.getColor() && indexer.getType())
            {
                item.itemName = indexer.itemName;
                item.itemPrice = indexer.itemPrice;
                item.itemImage = indexer.itemImage;
                item.itemDescription = indexer.itemDescription;
                item.shopName = "H&M";
                item.url = pageToIndex.Uri.ToString();
                item.itemGender = indexer.itemGender;

                item.itemColor = indexer.itemColor;
                item.itemType = indexer.itemType;
                return true;
            }
            return false;
        }
Beispiel #2
0
        private static bool indexUniqloPage(CrawledPage pageToIndex, ref ClothingItem item )
        {
            var indexer = new UniqloIndexer(pageToIndex);
            Console.WriteLine("aa : {0}", pageToIndex.Uri);
            if (indexer.getTitle() && indexer.getPrice() && indexer.getImage() && indexer.getDescription() && indexer.getColor() && indexer.getType())
            {
                item.itemName = indexer.itemName;
                item.itemPrice = indexer.itemPrice;
                item.itemImage = indexer.itemImage;
                item.itemDescription = indexer.itemDescription;
                item.shopName = "UNIQLO";
                item.url = pageToIndex.Uri.ToString();
                item.itemGender = indexer.itemGender;
                item.itemColor = indexer.itemColor;
                item.itemType = indexer.itemType;

                return true;
            }
            return false;
        }
Beispiel #3
0
 private static bool insertDB(ClothingItem item)
 {
     var cmd = myConnection.CreateCommand();
     cmd.CommandText = @"INSERT into SuperFashionDB.ShopItems (shopitemname, shopitemdescription, shopitemprice, shopitemurl, ShopName, pricerange, shopitemimgurl, shopitemimageurl, shopitemgender, shopitemcolor, shopitemtype, shopitemfilename ) values (@itemName,@itemDescription,@itemPrice,@url,@shopName, 1, @itemImage, @itemImage, @itemGender, @itemColor, @itemType, @itemFileName)";
     cmd.Parameters.AddWithValue("@itemName", item.itemName);
     cmd.Parameters.AddWithValue("@itemDescription", item.itemDescription);
     cmd.Parameters.AddWithValue("@itemPrice", item.itemPrice);
     cmd.Parameters.AddWithValue("@url", item.url);
     cmd.Parameters.AddWithValue("@shopName", item.shopName);
     cmd.Parameters.AddWithValue("@itemImage", item.itemImage);
     cmd.Parameters.AddWithValue("@itemGender", item.itemGender);
     cmd.Parameters.AddWithValue("@itemColor", item.itemColor);
     cmd.Parameters.AddWithValue("@itemType", item.itemType);
     cmd.Parameters.AddWithValue("@itemFileName", item.itemFileName);
     cmd.ExecuteScalar();
     return true;
 }
Beispiel #4
0
        private static bool indexPages(CrawledPage crawledPage)
        {
            ClothingItem item = new ClothingItem() ;
            ImageDownloader downloader = new ImageDownloader();
            if (indexUniqloPage(crawledPage, ref item))
            {
                Console.WriteLine("Found clothing item : {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", item.itemName, item.itemPrice, item.itemImage, item.itemDescription, item.shopName, item.url, item.itemGender, item.itemType, item.itemColor);
                item.generateImageFileName(".jpg");
                downloader.DownloadRemoteImageFile(item.itemImage, item.itemFileName);
                insertDB(item);
                return true;
            }
            if (indexHMPage(crawledPage, ref item))
            {
                Console.WriteLine("Found clothing item : {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", item.itemName, item.itemPrice, item.itemImage, item.itemDescription, item.shopName, item.url, item.itemGender, item.itemType, item.itemColor);
                item.generateImageFileName(".jpg");
                downloader.DownloadRemoteImageFile(item.itemImage, item.itemFileName);
                insertDB(item);
                return true;
            }
            if (indexZaraPage(crawledPage, ref item))
            {
                Console.WriteLine("Found clothing item : {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", item.itemName, item.itemPrice, item.itemImage, item.itemDescription, item.shopName, item.url, item.itemGender, item.itemType, item.itemColor);
                item.generateImageFileName(".jpg");
                downloader.DownloadRemoteImageFile(item.itemImage, item.itemFileName);
                insertDB(item);
                return true;
            }

            return false;
        }