Ejemplo n.º 1
0
        private void btn_getkeydata_zhu_Click(object sender, EventArgs e)
        {
            list_kd = new List <Entity_KeyData>();
            //获取关键词条数
            int length = browser.ToJsInt("document.getElementsByTagName('table')[1].getElementsByTagName('tr').length");

            //遍历获取关键词信息
            for (int i = 0; i < length; i++)
            {
                string key              = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[1].innerText");
                string xiangguan        = "";
                string sousuoredu       = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[2].innerText");
                string dianjiredu       = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[3].innerText");
                string dianjilv         = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[4].innerText");
                string zhuanhualv       = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[5].innerText");
                string jingzhengqiangdu = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[6].innerText");
                string chujia           = browser.ToJs("document.getElementsByTagName('table')[1].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[7].innerText");

                Entity_KeyData kd = new Entity_KeyData();

                try
                {
                    kd.Key              = key;
                    kd.Xiangguan        = xiangguan;
                    kd.Sousuoredu       = sousuoredu.ToInt();
                    kd.Dianjiredu       = dianjiredu.ToInt();
                    kd.Dianjilv         = dianjilv.Replace("%", "").ToDecimal() / 100;
                    kd.Zhuanhualv       = zhuanhualv.Replace("%", "").ToDecimal() / 100;
                    kd.Jingzhengqiangdu = jingzhengqiangdu.ToInt();
                    kd.Chujia           = chujia.ToDecimal();
                    kd.Dianjisousuo     = Convert.ToDecimal(kd.Dianjiredu) / Convert.ToDecimal(kd.Sousuoredu);
                    kd.Zonghezhi        = kd.Sousuoredu * kd.Dianjilv * kd.Zhuanhualv;
                    kd.Zonghejingzheng  = kd.Zonghezhi / kd.Jingzhengqiangdu;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                list_kd.Add(kd);
            }

            //附加到dgv
            dgv1.DataSource         = list_kd.ToDataTable();
            tabControl1.SelectedTab = tabPage1;
        }
Ejemplo n.º 2
0
        private void btn_search_zhu_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab = tp_kefus;

            //获取选择的关键词
            List <int> list = dgv1.GetCheckedIndex("确定要查询选中关键词吗?");

            //需要查询的关键词
            List <string> strs = new List <string>();

            foreach (var item in list)
            {
                strs.Add(dgv1.Rows[item].Cells[1].Value.ToString());
            }



            //遍历搜索关键词

            list_kdres = new List <Entity_KeyData>();


            foreach (var item in strs)
            {
                browser.ToJs("document.getElementsByClassName('keyword-search-input-box')[0].getElementsByTagName('input')[0].focus();");
                Common.Manager.Delay(500);
                Auto.Ctrl_A();
                Auto.Ctrl_V(item);
                Common.Manager.Delay(500);
                //browser.ToJs("getElementsByInnerText('查询')[0].click()");
                browser.ToMouseClick("getElementsByInnerText_NoChildren('查询')[0]");
                Common.Manager.Delay(4500);
                //开始获取关键词信息


                //获取关键词条数
                int length = browser.ToJsInt("document.getElementsByTagName('table')[3].getElementsByTagName('tr').length");
                //遍历获取关键词信息
                for (int i = 0; i < length; i++)
                {
                    string key              = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[1].innerText");
                    string xiangguan        = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[2].innerText");;
                    string sousuoredu       = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[3].innerText");
                    string dianjiredu       = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[4].innerText");
                    string dianjilv         = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[5].innerText");
                    string zhuanhualv       = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[6].innerText");
                    string jingzhengqiangdu = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[7].innerText");
                    string chujia           = browser.ToJs("document.getElementsByTagName('table')[3].getElementsByTagName('tr')[" + i + "].getElementsByTagName('td')[8].innerText");

                    Entity_KeyData kd = new Entity_KeyData();

                    try
                    {
                        kd.Key              = key;
                        kd.Xiangguan        = xiangguan;
                        kd.Sousuoredu       = sousuoredu.ToInt();
                        kd.Dianjiredu       = dianjiredu.ToInt();
                        kd.Dianjilv         = dianjilv.Replace("%", "").ToDecimal() / 100;
                        kd.Zhuanhualv       = zhuanhualv.Replace("%", "").ToDecimal() / 100;
                        kd.Jingzhengqiangdu = jingzhengqiangdu.ToInt();
                        kd.Chujia           = chujia.ToDecimal();
                        kd.Dianjisousuo     = Convert.ToDecimal(kd.Dianjiredu) / Convert.ToDecimal(kd.Sousuoredu);
                        kd.Zonghezhi        = kd.Sousuoredu * kd.Dianjilv * kd.Zhuanhualv;
                        kd.Zonghejingzheng  = kd.Zonghezhi / kd.Jingzhengqiangdu;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }

                    list_kdres.Add(kd);
                }
            }


            dgv2.DataSource         = list_kdres.ToDataTable();
            tabControl1.SelectedTab = tabPage2;
        }