Пример #1
0
        public List <NewsModel> Update()
        {
            Task task = new Task(() =>
            {
                try
                {
                    ParserWorker <NewsModel[]> parserWorker1 = new ParserWorker <NewsModel[]>(new LinkParser());
                    parserWorker1.Settings   = new NewsSettings(1, 5);
                    parserWorker1.OnNewData += (e, x) =>
                    {
                        foreach (var i in x)
                        {
                            list.Add(i);
                        }
                        IsComplited = true;
                    };
                    parserWorker1.Start();
                }
                finally
                {
                }
            });

            task.Start();
            while (true)
            {
                if (IsComplited == true)
                {
                    return(list);
                }
            }
        }
Пример #2
0
        string GetName(object arg1, string post)
        {
            ParserWorker<string> parser;

                parser = new ParserWorker<string>(new SiteParser());
                parser.OnNewData += Parser_OnNewData;
            }
Пример #3
0
        public AboutPage()
        {
            InitializeComponent();

            phone = new Book
            {
                bookId = "31249554",
                Title  = "",
                imgUrl = "ozon-st.cdn.ngenix.net/multimedia/1022948366.jpg"
            };
            BindingContext = this;


            parser = new ParserWorker <string[]>(
                new OzonParser()
                );

            parser.OnCompleted += Parser_OnCompleted;
            parser.OnNewData   += Parser_OnNewData;
            //  string html = @"<!DOCTYPE html>
            //<html>
            //<body>
            //<h2>HTML Image Parsing</h2>
            //<img src='https://www.w3schools.com/html/img_girl.jpg' alt='Girl in a jacket' width='500' height='600'>
            //</body>
            //</html>  ";
            //            var url = "https://oilprice.com/oil-price-charts#prices";
            //            var web = new HtmlWeb();
            //            var htmlDoc = web.Load(url);
            //       myImage.Source = HtmlParsing(html);
            //            myLabel.Text = HtmlParsing(url);
        }
Пример #4
0
        private void buttonChecking_Click(object sender, EventArgs e)
        {
            siteObject = ListSites.GetSite(GetLink);

            if (siteObject == null)
            {
                return;
            }

            dataGridView1.Rows.Clear();
            ChekEnable = false;

            ParserWorker <string[]> parserImg = new ParserWorker <string[]>(
                siteObject.CreatParserGetMainImg(),
                new HabraSettings(GetLink, "")
                );

            parserImg.OnNewData += Parser_OnNewDataImg;
            parserImg.OnError   += ParserImg_OnError;
            parserImg.Start();

            ParserWorker <Chapter[]> parser = new ParserWorker <Chapter[]>(
                siteObject.CreatParserGetChapters(),
                new HabraSettings(GetLink, siteObject.LinkToChapterList)
                );

            parser.OnNewData += Parser_OnNewDataChapter;
            parser.OnError   += Parser_OnError;
            parser.Start();
        }
Пример #5
0
        public MainForm()
        {
            InitializeComponent();

            FormBorderStyle = FormBorderStyle.FixedSingle;

            //Настройка парсера
            parser = new ParserWorker <ItemModel[]>(new RssFeedParser())
            {
                Settings = new RssFeedParserSettings()
            };

            parser.OnCompleted   += Parser_OnComlpeted;
            parser.OnNewData     += Parser_OnNewData;
            parser.OnOpenLink    += Parser_OnOpenLink;
            parser.OnDescription += Parser_OnDescription;

            //Установка параметров таймера
            timer.Interval = Properties.Settings.Default.Timer;
            timer.Tick    += new EventHandler(timer_Tick);


            currRssFeed       = parser.Settings.BaseUrl;
            currTimerSettings = Properties.Settings.Default.Timer;
        }
Пример #6
0
 public Form1()
 {
     InitializeComponent();
     parser = new ParserWorker <string[]>(new HabraParser());
     parser.OnNewDataRef += Parser_OnNewDataRef;
     parser.OnNewData    += Parser_OnNewData;
 }
Пример #7
0
        private void ButtonStart_Click(object sender, EventArgs e)
        {
            switch (ComboBoxSites.SelectedItem.ToString())
            {
            case "Habra":
                parser          = new ParserWorker <string[]>(new HabraParser());
                parser.Settings = new HabraSettings((int)NumericStart.Value, (int)NumericEnd.Value);
                break;

            case "Kino":
                parser          = new ParserWorker <string[]>(new KinoParser());
                parser.Settings = new KinoSettings(1, 1);
                break;

            case "Vk":
                parser          = new ParserWorker <string[]>(new VkParser());
                parser.Settings = new VkSettings(1, 1, TextBoxId.Text);
                break;

            default:
                parser          = new ParserWorker <string[]>(new HabraParser());
                parser.Settings = new HabraSettings((int)NumericStart.Value, (int)NumericEnd.Value);
                break;
            }

            parser.OnCompleted += Parser_OnComplited;
            parser.OnNewData   += Parser_OnNewData;
            parser.Start();
        }
Пример #8
0
        private void LinkParser_OnCompleted(object arg1, List <string> arg2)
        {
            var currentSettings = ((ParserWorker <List <string> >)arg1).Settings;

            if (currentSettings.LinkDeep > 1)
            {
                startParsing(new ParserSettingLink()
                {
                    LinkDeep = currentSettings.LinkDeep - 1, Url = currentSettings.Url
                });
            }

            foreach (var link in arg2)
            {
                var url = link;
                if (!IsValidUrl(link))
                {
                    url = currentSettings.Url + link;
                }
                var textSetting = new ParserSettingLink()
                {
                    Url = url
                };
                textParser = new ParserWorker <string>(new TextParser(), textSetting);
                textParser.Start();
                textParser.OnCompleted += TextParser_OnCompleted;
            }
        }
Пример #9
0
 private void LoadInternet(object sender, RoutedEventArgs e)
 {
     if (isRunning || listCollection != null)
     {
         if (parser.IsActive)
         {
             parser.Abort();
         }
         listAbiturient.ItemsSource = null;
         listCollection.Clear();
         listab.Clear();
         listTarget.Clear();
         listSpecial.Clear();
     }
     else
     {
         listCollection = new List <Abiturient>();
         listab         = new List <Abiturient>();
         listTarget     = new List <Abiturient>();
         listSpecial    = new List <Abiturient>();
     }
     currentPage             = 1;
     parser                  = new ParserWorker <string[]>(new VuzParser());
     parser.OnNewData       += Parser_OnNewData;
     parser.Settings         = new VuzSettings(startPage, int.Parse(endPageTB.Text));
     parser.Settings.BaseUrl = linkTB.Text;
     parser.Start();
     isRunning = true;
 }
Пример #10
0
 public Form1()
 {
     InitializeComponent();
     parser              = new ParserWorker <string[]>(new HabraPrser());
     parser.OnCompleted += Parser_OnComplited;
     parser.OnNewData   += Parser_OnNewData;
 }
Пример #11
0
        //получаем новые новости
        static void Get2chNews(object obj)
        {
            ParserWorker <string[]> parser = (ParserWorker <string[]>)obj;

            Console.WriteLine("..:: Обновление новостей ::..\n" + DateTime.Now.ToLongTimeString());
            parser.Start();
        }
Пример #12
0
        public NewBookEdit()
        {
            Title = "ДОБАВЛЕНИЕ КНИГИ";
            InitializeComponent();

            book = new Book
            {
                BookTitle       = "",
                BookAuthor      = "",
                BookCategory    = "",
                BookDescription = "",
                ISBNnumber      = "",
                BookImagePath   = "icon.png"
            };
            BindingContext = this;

            CategoryList = new ObservableCollection <Category>(app.Database.GetCategories().ToList());
            book_category.ItemsSource = CategoryList;

            parser     = new ParserWorker <string[]>(new OzonParser());
            parserIsbn = new ParserWorker <string[]>(new AmazonParser());

            parser.OnCompleted     += Parser_OnCompleted;
            parser.OnNewData       += Parser_OnNewData;
            parserIsbn.OnCompleted += Parser_OnCompleted;
            parserIsbn.OnNewData   += Parser_OnNewData;
            //            book_isbn.Text = "9785941575381";

            if (OzonBookId.Text != null)
            {
                ButtonStart_Click(this, EventArgs.Empty);
                parser.Settings = new OzonSettings(OzonBookId.Text);
                parser.Start();
            }
        }
Пример #13
0
        //получаем новые новости
        static void GetNewsUpdate(object obj)
        {
            ParserWorker <string[]> parser = (ParserWorker <string[]>)obj;

            Console.WriteLine("..:: Обновление контента ::..\n" + DateTime.Now.ToLongTimeString());
            parser.Start();
        }
Пример #14
0
        public DatabaseParserUpdater()
        {
            parser  = new ParserWorker <Match[]>(new MatchParser(), new MatchSettings());
            list    = new List <MatchEntity>();
            leagues = Available.Leagues.ToArray();
            coeffs  = new List <CoeffEntity>();


            parser.OnNewData += (matches, league) =>
            {
                foreach (var match in matches)
                {
                    MatchEntity row = new MatchEntity();

                    row.StartTime = match.StartTime;
                    row.Teams     = match.Teams;
                    row.League    = league;

                    foreach (var coeff in match.Coeffs)
                    {
                        CoeffEntity item = new CoeffEntity();

                        item.Coefficient = coeff.Value;
                        item.Formula     = coeff.Formula;
                        item.Holder      = row;
                        coeffs.Add(item);
                    }

                    list.Add(row);
                }
            };
        }
Пример #15
0
        public FormMain()
        {
            InitializeComponent();
            parser = new ParserWorker <string[]>(new AvitoParser());

            parser.OnCompleted += Parser_OnCompleted;
            parser.OnNewData   += Parser_OnNewData;
        }
Пример #16
0
        public Form1()
        {
            InitializeComponent();
            parser = new ParserWorker <List <FreelanceTask> >(new FreelanceParcer(), new FreelanceSettings());

            parser.onNewData   += Parser_onNewData;
            parser.OnCompleted += Parser_OnCompleted;
        }
Пример #17
0
 public Form1()
 {
     InitializeComponent();
     //parser = new ParserWorker<string[]>(new BankParser());
     parser             = new ParserWorker <ExchangeRates[]>(new BankParser());
     parser.OnComplite += Parser_OnComplite;
     parser.OnNewData  += Parser_OnNewData;
 }
Пример #18
0
        public MainWindow()
        {
            InitializeComponent();
            parser = new ParserWorker <AvitoNote[]>(new AvitoParser());

            parser.OnComleted += Parser_OnComleted;
            parser.OnNewData  += Parser_OnNewData;
        }
Пример #19
0
        public Form1()
        {
            parser = new ParserWorker <string[]>(new WorkParser());
            InitializeComponent();

            parser.OnComplete += Parser_OnComplete;
            parser.OnNewData  += Parser_OnNewData;
        }
Пример #20
0
        public Form1()
        {
            InitializeComponent();

            parser                   = new ParserWorker <HabrModel[]>(new HabrParserObject());
            parser.OnNewData        += Parser_OnNewData;
            parser.OnParseCompleted += Parser_OnParseCompleted;
        }
Пример #21
0
        /// <summary>
        /// Start VisualCron parser
        /// </summary>
        /// <param name="startPoint">Start point. For example: page id</param>
        /// <param name="endPoint">End point. For example: page end id</param>
        /// <param name="threadCount">Parse thread count</param>
        private static void StartVC(int startPoint, int endPoint, int threadCount = 1)
        {
            ParserWorker <VisualCronModel> worker = new ParserWorker <VisualCronModel>(new VisualCronParser(), new VisualCronParserSettings(startPoint, endPoint, threadCount));

            worker.OnCompleted     += Worker_OnCompleted;
            worker.OnNewData       += Worker_OnNewData;
            worker.OnPageCompleted += Worker_OnPageCompleted;
            worker.Start();
        }
Пример #22
0
 public MainWindow()
 {
     InitializeComponent();
     parser = new ParserWorker <string[]>(
         new OsParser()
         );
     parser.OnCompleted += Parser_OnCompleted;
     parser.OnNewData   += Parser_OnNewData;
 }
Пример #23
0
 public MainForm()
 {
     InitializeComponent();
     _parser = new ParserWorker <string[]>(
         new ElectronshikParser()
         );
     _parser.OnCompleted += Parser_OnCompleted;
     _parser.OnNewData   += Parser_OnNewData;
 }
Пример #24
0
        public FormWorker()
        {
            parser = new ParserWorker <string[]>(
                new HabraParser()
                );

            parser.OnCompleted += Parser_OnCompleted;
            parser.OnNewData   += Parser_OnNewData;
        }
Пример #25
0
        public void Get()
        {
            ParserWorker <string> Parser;

            Parser            = new ParserWorker <string>(new EstoreParser());
            Parser.OnNewData += Parser_OnNewData;
            Parser.Settings   = new EstoreSettings();
            Parser.Start();
        }
Пример #26
0
 public Form1()
 {
     InitializeComponent();
     parserMP = new ParserWorker <string[]>(
         new MainPageParser()
         );
     parserMP.OnComplited += Parser_OnCompleted;
     parserMP.OnNewData   += Parser_OnNewDataMP;
 }
Пример #27
0
        static public IEnumerable <BaseExchanger> Run()
        {
            ParserWorker <BaseExchanger[]> worker = new ParserWorker <BaseExchanger[]>(new SiteParser(), addresses);

            worker.OnNewData   += Parse_OnNewData;
            worker.OnCompleted += Parse_OnCompleted;
            worker.Start();
            return(exchangers);
        }
Пример #28
0
        public MainForm()
        {
            InitializeComponent();
            parser = new ParserWorker <List <string> >(
                new SiteParser());

            parser.OnCompleted += Parser_OnCompleted;
            parser.OnNewData   += Parser_OnNewData;
        }
Пример #29
0
 public override async void Execute(Message message, TelegramBotClient client)
 {
     parser          = new ParserWorker <string[]>(new AvitoParser());
     parser.Settings = new AvitoSettings(1, 5);
     parser.Start();
     parser.OnNewData += Parser_OnNewData;
     Thread.Sleep(5000);
     await client.SendTextMessageAsync(message.Chat.Id, temp);
 }
Пример #30
0
        public async Task <ActionResult> ParseStart()
        {
            int start = 1;
            int end   = 1;

            if (Request.Params["start"] != null)
            {
                start = Int32.Parse(Request.Params["start"]);
            }

            if (Request.Params["end"] != null)
            {
                end = Int32.Parse(Request.Params["end"]);
            }

            List <Product> newProductsList = new List <Product>();

            ParserWorker <List <Product> > parser = new ParserWorker <List <Product> >(
                new SiteParser(),
                new SiteSettings(start, end)
                );

            for (int i = parser.Settings.StartPoint; i <= parser.Settings.EndPoint; i++)
            {
                var source = await parser.Loader.GetSourceByPageId(i);

                var domParser = new HtmlParser();
                var document  = await domParser.ParseAsync(source);

                var result = parser.Parser.Parse(document);

                newProductsList.AddRange(result);
            }

            foreach (var product in newProductsList)
            {
                Product matches = db.Products.FirstOrDefault(p => p.Name == product.Name);

                if (matches == null)
                {
                    string imgPath  = parser.Settings.BaseUrl + product.ImgUrl;
                    string fileName = System.IO.Path.GetFileName(imgPath);
                    string newPath  = Server.MapPath("~/Images/Catalog/") + System.IO.Path.GetFileName(fileName);

                    await FilesLoader.DownloadFileAsync(imgPath, newPath);

                    product.ImgName = fileName;

                    db.Products.Add(product);
                }
            }

            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }