Exemplo n.º 1
0
        private void urlTextbox_KeyDown(object sender, KeyEventArgs e)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (e.Key)
            {
            case Key.Return:
            {
                MainBrowser.Stop();

                var result = ValidHttpUrl(urlTextbox.Text, out var uriResult);
                if (!result)
                {
                    MainBrowser.Address = "https://google.com/search?q=" + urlTextbox.Text;
                }
                else
                {
                    MainBrowser.Address = uriResult?.AbsoluteUri;
                }

                MainBrowser.Focus();
                break;
            }

            case Key.Escape:
                MainBrowser.Focus();
                break;
            }
        }
Exemplo n.º 2
0
        async void HladajButton_Click(object sender, EventArgs e)
        {
            dataGridView1.Visible = false;
            dataGridView1.Columns.Clear();
            lines.Clear();

            MainBrowser.Navigate("https://cp.hnonline.sk/" + GetTransportMethod() + "/odchody/");
            await PageLoad(10);

            MainBrowser.Focus();

            SendKeys.Send("%{o}");         //access key which selects the field
            SendKeys.Send(ZTextBox.Text);

            SendKeys.Send("%{k}");
            SendKeys.Send(DoTextBox.Text);

            SendKeys.Send("%{t}");
            SendKeys.Send(datumPicker.Value.ToString("d.M.yyyy"));

            SendKeys.Send("%{a}");
            SendKeys.Send("00:00");

            SendKeys.SendWait("{ENTER}");
            await PageLoad(10);
            await PageLoad(10);

            var tr = MainBrowser.Document.GetElementsByTagName("tr");

            Regex rL = new Regex(@"javascript:.+?\)");

            List <string> pages = rL.Matches(tr[1].InnerHtml).Cast <Match>().Select(match => match.Value).ToList();

            await GetLinesFromPage("", tr);

            foreach (string page in pages)
            {
                await GetLinesFromPage(page, tr);
            }
            dataGridView1.Visible = true;
            ShowResults();
        }