Beispiel #1
0
        private void 分析AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (var page in JianWrapper.GetJian().Pages)
            {
                var url = page.Url;

                foreach (var interest in page.Interests.Keys)
                {
                    var xpath = page.Interests[interest].Pattern;

                    WebDriverWrapper.GetDriver().Navigate().GoToUrl(url);

                    var wait = new WebDriverWait(WebDriverWrapper.GetDriver(), TimeSpan.FromSeconds(120));

                    try
                    {
                        wait.Until(d => FindElement(d, xpath));
                        var element = FindElement(WebDriverWrapper.GetDriver(), xpath);
                        page.Interests[interest].Value = element.Text;
                    }
                    catch (Exception)
                    {
                        page.Interests[interest].Value = "查找失败。(请重试或者在设置中修改特征字符)";
                    }
                }
            }

            WebDriverWrapper.Close();

            JianWrapper.GetJian().SaveToFile();
            ReloadSetting();

            MessageBox.Show("分析完毕。");
        }
Beispiel #2
0
 private void ReloadSetting()
 {
     dg.DataSource = JianWrapper.LoadFromFile().ToDataTable();
     dg.Refresh();
 }
Beispiel #3
0
 private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)
 {
     JianWrapper.GetJian().SaveToFile();
 }
Beispiel #4
0
 private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)
 {
     JianWrapper.GetJian().FromDataTable(dg.DataSource as DataTable, false).SaveToFile();
 }
Beispiel #5
0
 private void LoadSetting()
 {
     dataGridView1.DataSource = JianWrapper.LoadFromFile().ToDataTable(true);
     dataGridView1.Refresh();
 }