Example #1
0
        public static void Main(string[] args)
        {
            var conn = new ConnectSQL();

            ConnectSQL.Connect("mysql-Username", "mysql-Password");

            var scrape  = new scrape();
            var results = scrape.scraper();

            foreach (var stock in results)
            {
                Console.WriteLine(stock);
            }
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            //Check to see if user selected any prefilled site info:
            if (!String.IsNullOrEmpty(prefilledSite))
            {
                _logger.LogInformation($"Using pre-filled info:{prefilledSite}");
                var siteData = new FormattedSites();
                siteData.formattedSitesDict.TryGetValue(prefilledSite, out List <string> priceNamesList);
                Console.WriteLine($"FOUND: {priceNamesList[0]}+ {priceNamesList[1]}");
                //When using prefilled info, it's always in the same order: price, name
                priceId       = priceNamesList[0];
                productNameId = priceNamesList[1];
            }
            var productMeta = new ProductMeta
            {
                ProductUrl  = url,
                PriceHtmlId = priceId,
                NameHtmlId  = productNameId,
                VanityName  = vanityName
            };

            try
            {
                //Save changes to database and scrape the newly added product.
                _context.ProductMeta.Add(productMeta);
                await _context.SaveChangesAsync();

                scrape scraper = new scrape(_context);
                scraper.ScrapeSingle(productMeta.ProductUrl, productMeta.PriceHtmlId, productMeta.NameHtmlId, productMeta.Id, _context);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Error Saving to database:");
            }
            return(RedirectToPage("SavedProducts"));
        }
Example #3
0
 assertTrue(scrape.list.get("title").data.indexOf("<title>") > 0);
Example #4
0
 AssertEquals(scrape.list.get("title").type, "text");
Example #5
0
 AssertEquals(scrape.address, "http://localhost:9090/");
Example #6
0
 AssertEquals(scrape.section, "one");