Beispiel #1
0
        static async Task Main(string[] args)
        {
            var scraper = new WebScraperService();
            var result  = await scraper.ScrapeWebsite("https://www.dn.se/nyheter/nutidstestet/nutidstestet-vecka-44-6/");

            Console.ReadLine();
        }
Beispiel #2
0
        private void frmShoeSelection_Load()
        {
            _service   = new WebScraperService();
            _presenter = new WebScraperPresenter(this, _service);
            _presenter.DisplayWebsites();
            _presenter.PageSize = PAGESIZE;

            staMessage.Text = "Ready";

            _service.SelectionCommittedEvent += TestEBaySubSystemHandler;
        }
        public ScrapeableSource SearchByName(string speciesName)
        {
            var url  = "https://aquarium-fish.liveaquaria.com/search?w=" + Uri.EscapeUriString(speciesName);
            var body = WebScraperService.RetrievePage(_uri);

            return(new ScrapeableSource()
            {
                Definition = this,
                SpeciesName = speciesName,
                WebsiteSource = speciesName
            });
        }
Beispiel #4
0
        private static int Main(string[] args)
        {
            BrowserForm browser;

            Starter.Initialize(args);
            if (args.Length == 0)
            {
                MainForm form = new MainForm();
                Application.Run(form);
            }
            else if (args.Length == 1)
            {
                browser = new BrowserForm();
                Thread thread = new Thread(() =>
                {
                    GmailService service = GmailAnnonceService.GetGmailService();
                    var gmailmessages    = GmailAnnonceService.GetMessages(service);
                    Thread.Sleep(2000);
                    foreach (var message in gmailmessages)
                    {
                        WebScraperService.RunScrapping(browser, args[0].Split('/')[5], message);
                    }
                    Application.Exit();
                });
                thread.Start();
                Application.Run(browser);
            }
            else
            {
                browser = new BrowserForm();
                Thread thread = new Thread(() =>
                {
                    Thread.Sleep(2000);
                    List <Annonce> lists = new List <Annonce>();
                    if (args.Length > 1)
                    {
                        lists.Add(new Annonce(DateTime.Now, args[0], long.Parse(args[1])));
                    }
                    else
                    {
                        lists.Add(new Annonce(DateTime.Now, args[0]));
                    }
                    WebScraperService.RunScrapping(browser, args[0].Split('/')[5], lists);
                    Application.Exit();
                });
                thread.Start();
                Application.Run(browser);
            }

            return(0);
        }
        public HttpResponseMessage SavePost(ScrapedPost model)
        {
            int res = 0;
            WebScraperService svc = new WebScraperService();

            try
            {
                res = svc.SavePost(model);
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
        public HttpResponseMessage GetAll()
        {
            List <ScrapedPost> res = new List <ScrapedPost>();
            WebScraperService  svc = new WebScraperService();

            try
            {
                res = svc.GetAll();
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            var url = textBox1.Text;

            browser = new BrowserForm();
            browser.Show();
            Thread thread = new Thread(() =>
            {
                GmailService service = GmailAnnonceService.GetGmailService();
                var gmailmessages    = GmailAnnonceService.GetMessages(service);
                Thread.Sleep(2000);
                foreach (var message in gmailmessages)
                {
                    WebScraperService.RunScrapping(browser, url.Split('/')[5], message);
                }
            });

            thread.Start();
        }
Beispiel #8
0
        public void ApplyToSpecies(Uri url, Species species)
        {
            _body = WebScraperService.RetrievePage(url);
            _uri  = url;


            species.CareLevel      = GetCareLevel();
            species.PrimaryColor   = GetPrimaryColor();
            species.SecondaryColor = GetSecondaryColor();
            species.MinimumGallons = GetMinimumGallons();
            species.Lifespan       = GetLifespan();
            species.PhMin          = GetPhMin();
            species.PhMax          = GetPhMax();
            species.TemperatureMin = GetTemperatureMin();
            species.TemperatureMax = GetTemperatureMax();
            species.Description    = GetDescription();
            species.Thumbnail      = GetThumbnail();
            species.MaxSize        = GetMaxSize();
            species.Price          = GetPrice();
        }
Beispiel #9
0
 public WebScraperPresenter(IWebScraperView webscraperView, WebScraperService webscraperService)
 {
     _view    = webscraperView;
     _service = webscraperService;
     _service.ScrapeCompletedEvent += DataLoadedHandler;
 }