示例#1
0
        public static List <ScrapeSource> GetAllDetailList()
        {
            LogHelper.log.Info("scrape data list start");
            List <ScrapeSource> list    = new List <ScrapeSource>();
            var           zipCodeList   = new List <string>();
            var           file          = ConfigurationManager.AppSettings.Get("CountyZipFile").ToString();
            var           json          = File.ReadAllText(file);
            var           countyZipList = JsonConvert.DeserializeObject <List <CountyZipModel> >(json);
            DayCareScrape me            = new DayCareScrape("http://www.dleg.state.mi.us");

            foreach (var c in countyZipList)
            {
                if (c.UseCounty)
                {
                    Console.WriteLine("Scape by county:" + c.County);
                    try
                    {
                        var url = string.Format("/brs_cdc/rs_lfl.asp?cdc_name=&address=&cnty_name={0}&cdc_city=&cdc_zip=&ftype=DC&lic_name=&lic_nbr=&Search=Search&sorry=yes", c.County);
                        me.ExtractDayCareList(url, list, c.County, "");
                    }
                    catch (Exception ex)
                    {
                        LogHelper.log.Info("Scape by county:" + c.County + "exception:" + ex.ToString());
                    }
                    Console.WriteLine("Scape by county:" + c.County + "end...");
                }
                else
                {
                    foreach (var r in c.ZipCodeList)
                    {
                        Console.WriteLine("Scape by zipCode:" + r.ZipCode);
                        try
                        {
                            var url = string.Format("/brs_cdc/rs_lfl.asp?cdc_name=&address=&cnty_name=%25&cdc_city=&cdc_zip={0}&ftype=DC&lic_name=&lic_nbr=&Search=Search&sorry=yes", r.ZipCode.ToString());
                            me.ExtractDayCareList(url, list, c.County, r.ZipCode);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.log.Info("Scape by zipCode:" + r.ZipCode + "exception:" + ex.ToString());
                        }
                        Console.WriteLine("Scape by zipCode:" + r.ZipCode + "end...");
                    }
                }
            }
            LogHelper.log.Info("scrape data list end");
            return(list);
        }