Ejemplo n.º 1
0
        private static void Fetchlist()
        {
            int       page      = 1;
            int       maxPage   = 1;
            string    startPage = "https://mobile-api.rewe.de/mobile/products/search?withFacets=true&storeId=241108&objectsPerPage=250&page=";
            WebClient client    = new WebClient();

            QueryList initQuery = JsonConvert.DeserializeObject <QueryList>(client.DownloadString(startPage + page.ToString()));

            maxPage = initQuery.pageCount;
            ExcelController excel = new ExcelController(@"XLS PATH");

            for (page = 1; page <= maxPage; page++)
            {
                Console.WriteLine("=== CRAWLING PAGE " + page + "/" + maxPage + "===");
                QueryList query = JsonConvert.DeserializeObject <QueryList>(client.DownloadString(startPage + page.ToString()));
                foreach (Product product in query.products)
                {
                    try
                    {
                        ReweProdukt curProduct = new ReweProdukt(product.productId);
                        excel.InsertRow(curProduct);
                    }
                    catch { continue; }
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public void InsertRow(ReweProdukt product)
 {
     try
     {
         int newRow = lastRow();
         //Console.WriteLine(newRow);
         sheet.Cells[newRow + 1, 1].Value = product.imgUrl;
         sheet.Cells[newRow + 1, 2].Value = product.productName;
         sheet.Cells[newRow + 1, 3].Value = product.servingSize + " " + product.servingEinheit;
         sheet.Cells[newRow + 1, 4].Value = product.kcal.value;
         sheet.Cells[newRow + 1, 5].Value = product.fett.value;
         sheet.Cells[newRow + 1, 6].Value = product.kohlenhydrate.value;
         sheet.Cells[newRow + 1, 7].Value = product.eiweiß.value;
         sheet.Cells[newRow + 1, 8].Value = product.salz.value;
         sheet.Cells[newRow + 1, 9].Value = product.price;
     }
     catch (Exception ex)
     {
         //Console.WriteLine(ex.Message);
     }
 }