示例#1
0
        public void Download()
        {
            foreach (var link in this.Links.Select(uri => "http://" + uri.Authority + uri.AbsolutePath).Distinct())
            {
                Console.WriteLine(link);

                var project = new Project();

                using (Stream htmlStream = new WebClient().OpenRead(link))
                {
                    var doc = new HtmlDocument();
                    doc.Load(htmlStream);

                    project.Name = GetName(doc);

                    project.Company = GetCompany(doc);

                    project.Description = GetProjectDescription(doc);

                    project.TotalFunding = GetFunding(doc);

                    project.FundingGoal = GetFundingGoal(doc);

                    project.Backers = GetTotalProjectBackers(doc);

                    Currency currency;
                    if (Currency.TryParse(GetCurrency(doc), out currency))
                    {
                        project.Currency = currency;
                    }
                    else
                    {
                        Console.WriteLine("CURRENCY NOT FOUND" + GetCurrency(doc));
                        continue;
                    }

                    project.Link = GetLink(doc);

                    project.FundingSucceeded = GetFundingSucceeded(doc);

                    project.Levels.AddRange(GetLevels(doc, project.Currency));

                   // project.StartDate = GetStartDate(doc);

                    project.EndDate = GetEndDate(doc);

                    project.Category = GetCatgory(doc);

                    this.Projects.Add(project);
                }
            }
        }
示例#2
0
        public void Download()
        {
            foreach (var link in this.Links)
            {
                var project = new Project();

                Stream htmlStream = new WebClient().OpenRead(link);

                HtmlDocument doc = new HtmlDocument();
                doc.Load(htmlStream);

                project.Name = GetName(doc);

                project.Company = GetCompany(doc);

                project.Description = GetProjectDescription(doc);

                project.TotalFunding = GetFunding(doc);

                project.FundingGoal = GetFundingGoal(doc);

                project.Backers = GetTotalProjectBackers(doc);

                project.Currency = GetCurrency(doc);

                project.Link = GetLink(doc);

                project.FundingSucceeded = GetFundingSucceeded(doc);

                project.Levels.AddRange(GetLevels(doc));

                project.StartDate = GetStartDate(doc);

                project.EndDate = GetEndDate(doc);

                project.Category = GetCatgory(doc);

                this.Projects.Add(project);
            }
        }