Ejemplo n.º 1
0
        private bool CreateZRSearchTask(STKeyInfo keyInfo)
        {
            createNativeURL("www.taobao.com", "www.baidu.com");
            createInputText("q", keyInfo.m_keyword, ElementTag.ID, 0);
            createClickButton("btn-seasrch", ElementTag.className, 0);

            if (keyInfo.isZTCClick() == false)
            {
                if (keyInfo.m_sortType == 1)
                {
                    createClickLink("人气", ElementTag.outerText);
                }else if (keyInfo.m_sortType == 2)
                {
                    createClickLink("销量", ElementTag.outerText);
                }
            }
            if (keyInfo.m_startPrice < keyInfo.m_endPrice)
            {
                createInputText("start_price", keyInfo.m_startPrice.ToString(), ElementTag.name, 0);
                createInputText("end_price", keyInfo.m_endPrice.ToString(), ElementTag.name, 0);
                createClickButton("确定", ElementTag.outerText, 2);
            }

            if (keyInfo.m_startPage < keyInfo.m_endPage && keyInfo.m_startPage != 1)
            {
                createInputText("page-num", keyInfo.m_startPage.ToString(), ElementTag, 0);
                createClickLink();
            }
        }
Ejemplo n.º 2
0
        public bool selectKeywordInfo(ref STKeyInfo keyInfo)
        {
            try
            {
                int count = listView1.Items.Count;
                if (count == 0)
                {
                    return false;
                }
                int selectIndex = rndGenerator.Next(0, count);
                keyInfo = keyInfoCollection[selectIndex];

                return true;
            }
            catch (System.Exception ex)
            {
                FileLogger.Instance.LogInfo(ex.StackTrace);
                FileLogger.Instance.LogInfo("Error select keyword");
                return false;
            }
            return true;
        }
Ejemplo n.º 3
0
        private void SimulateVisitThreadNew()
        {
            bool bRet = false;
            int expireTimer = getExpireTime() * 60 * 1000;
            try
            {
                int loopCnt = Convert.ToInt32(broswerNumTXT.Text.Trim());

                int uaCollectCount = broswerUACollection.Count;
                for (int index = 1; index <= loopCnt; index++)
                {

                    //int for loop
                    STKeyInfo keyInfo = new STKeyInfo();
                    keyInfo.initSTKeyInfo();

                    bRet = selectKeywordInfo(ref keyInfo);
                    if (bRet == false)
                    {
                        FileLogger.Instance.LogInfo("选择关键词失败");
                        continue;
                    }

                    string uaString = "";
                    string uaCaptionStr = "";
                    if (uaCollectCount != 0)
                    {
                        int uaIndex = rndGenerator.Next(0, uaCollectCount);
                        uaString = broswerUACollection[uaIndex].m_uaContent;
                        uaCaptionStr = broswerUACollection[uaIndex].m_uaDesc;
                    }
                    keyInfo.m_ztcTitle = ztcTextBox.Text.Trim().ToString();
                    string searchName = "第 " + index + " 个," + "关键词:" + keyInfo.m_keyword + "";
                    FileLogger.Instance.LogInfo(searchName);

                    LogInfoTextBox.Text += "==============================================================\n";
                    LogInfoTextBox.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + searchName + "\n";
                    if (isDebugCB.Checked == false)
                    {
                        bRet = changeVPN();
                        if (bRet == false)
                        {
                            FileLogger.Instance.LogInfo("切换VPN失败");
                            LogInfoTextBox.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "切换VPN失败" + "\n";
                            continue;
                        }
                    }
                    SimulateTab simulateTab = new SimulateTab(keyInfo, uaString, this, expireTimer);
                    simulateInfoText.Text = " IP:" + curSelectComboboxName.ToString() + " 系统浏览器[版本号]:" + uaCaptionStr + " " + searchName;
                    Application.Run(simulateTab);
                    GC.Collect();
                    if (isDebugCB.Checked == false)
                    {
                        bRet = disconnectVPN();
                        bRet = runCClean();
                        if (bRet)
                        {
                            FileLogger.Instance.LogInfo("cookie清理干净了");
                            LogInfoTextBox.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "cookie清理干净了" + "\n";
                        }
                        else
                        {
                            FileLogger.Instance.LogInfo("cookie清理失败了");
                            LogInfoTextBox.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "cookie清理失败了" + "\n";
                        }
                        bRet = runNiuBDASHI();
                    }

                    LogInfoTextBox.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "下一个任务" + "\n";

                    FileLogger.Instance.LogInfo("下一个任务!");
                    if (simulateTab.isNormalQuit == false)
                    {
                        FileLogger.Instance.LogInfo("手动停止!");
                        break;
                    }
                }
            }
            catch (Exception error)
            {
                FileLogger.Instance.LogInfo("Error:" + error.Message);
                FileLogger.Instance.LogInfo("StackTrace:" + error.StackTrace);
                nonParameterThread1.Abort();
                MessageBox.Show(error.Message, "error!");
                Console.WriteLine(error.Message.ToString());
                Console.WriteLine(error.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public bool LoadAllSeclecKeyword()
        {
            try
            {
                foreach (ListViewItem item in listView1.Items)
                {
                    STKeyInfo keyInfo = new STKeyInfo();
                    keyInfo.initSTKeyInfo();

                    keyInfo.m_keyword = item.SubItems[0].Text.Trim();
                    keyInfo.m_sortType = sortTypeCollect.IndexOf(item.SubItems[1].Text.Trim());
                    string pageRange = @"(.*)-(.*)";
                    Regex pageRangeRegex = new Regex(pageRange);
                    MatchCollection matches = pageRangeRegex.Matches(item.SubItems[2].Text.Trim());

                    foreach (Match m in matches)
                    {
                        Int32.TryParse(m.Groups[1].Value.Trim(), out keyInfo.m_startPage);
                        Int32.TryParse(m.Groups[2].Value.Trim(), out keyInfo.m_endPage);
                    }

                    string priceStr = item.SubItems[3].Text.Trim();
                    if (priceStr.Contains('-'))
                    {
                        string startPriceStr = priceStr.Substring(0, priceStr.IndexOf('-'));
                        string endPriceStr = priceStr.Substring(priceStr.IndexOf('-') + 1);
                        float.TryParse(startPriceStr, out keyInfo.m_startPrice);
                        float.TryParse(endPriceStr, out keyInfo.m_endPrice);
                    }

                    keyInfoCollection.Add(keyInfo);
                }
            }
            catch (System.Exception ex)
            {
                FileLogger.Instance.LogInfo(ex.StackTrace);
                FileLogger.Instance.LogInfo("Error select keyword");
                return false;
            }
            return true;
        }
Ejemplo n.º 5
0
        private bool CreateZRSearchTask(STKeyInfo keyInfo)
        {
            TaskInfo task = new TaskInfo("4", "www.taobao.com", "", "", "");
            this._testTask.Insert(task, -1);
            task = new TaskInfo(((int)(TaskCommand.Task_InputText)).ToString(), "q", keyInfo.m_keyword, "", "");
            this._testTask.Insert(task, -1);
            task = new TaskInfo("2", "btn-search", "3", "", "");
            this._testTask.Insert(task, -1);

            if (keyInfo.isZTCClick() == false)
            {
                if (keyInfo.m_sortType == 2)
                {
                    task = new TaskInfo(((int)(TaskCommand.Task_ClickLink)).ToString(), "人气", "", ((int)ElementTag.outerText).ToString(), "0");
                    _testTask.Insert(task, -1);
                    //createClickLink("人气", "", ElementTag.outerText, 0);
                }else if (keyInfo.m_sortType == 1)
                {
                    task = new TaskInfo(((int)(TaskCommand.Task_ClickLink)).ToString(), "销量", "", ((int)ElementTag.outerText).ToString(), "0");
                    _testTask.Insert(task, -1);
                    //createClickLink("销量", "", ElementTag.outerText, 0);
                }
            }
            if (keyInfo.m_startPrice < keyInfo.m_endPrice)
            {
                task = new TaskInfo(((int)(TaskCommand.Task_InputText)).ToString(), "start_price", keyInfo.m_startPrice.ToString(), ((int)ElementTag.name).ToString(), "0");
                this._testTask.Insert(task, -1);
                task = new TaskInfo(((int)(TaskCommand.Task_InputText)).ToString(), "end_price", keyInfo.m_endPrice.ToString(), ((int)ElementTag.name).ToString(), "0");
                this._testTask.Insert(task, -1);
                task = new TaskInfo(((int)(TaskCommand.Task_ClickButton)).ToString(), "确定", ((int)ElementTag.outerText).ToString(), "1", "");
                this._testTask.Insert(task, -1);
                //createInputText("start_price", keyInfo.m_startPrice.ToString(), ElementTag.name, 0);
                //createInputText("end_price", keyInfo.m_endPrice.ToString(), ElementTag.name, 0);
                //createClickButton("确定", ElementTag.outerText, 1);
            }

            int defaultMaxPage = 50;
            if (keyInfo.m_startPage < keyInfo.m_endPage && keyInfo.m_startPage != 1)
            {
                task = new TaskInfo(((int)(TaskCommand.Task_GoPage)).ToString(), keyInfo.m_startPage.ToString(), "", "", "");
                _testTask.Insert(task, -1);

                defaultMaxPage = keyInfo.m_endPage - keyInfo.m_startPage;
                //createGoPage( keyInfo.m_startPage.ToString());
            }

            if (keyInfo.isZTCClick() == false)
            {
                task = new TaskInfo(((int)TaskCommand.Task_FindLinkLinkPage1).ToString(), keyInfo.m_zrWangwangName, "下一页", defaultMaxPage.ToString(), "");
                _testTask.Insert(task, -1);
            }
            else
            {
                task = new TaskInfo(((int)TaskCommand.Task_FindLinkLinkPage1).ToString(), keyInfo.m_ztcTitle, "下一页", defaultMaxPage.ToString(), "");
                _testTask.Insert(task, -1);
            }

            if (compareCB.Checked)
            {
                int randCompare = rndGenerator.Next(1, 4);
                for (int i = 0; i < randCompare; i++)
                {
                    int rndCmpTime = rndGenerator.Next(5, 13);
                    task = new TaskInfo(((int)TaskCommand.Task_ClickCompare).ToString(), "http://detail.tmall.com/item.htm", "http://item.taobao.com/item.htm", "", "");
                    _testTask.Insert(task, -1);
                    task = new TaskInfo(((int)TaskCommand.Task_VisitCompare).ToString(), rndCmpTime.ToString(), i.ToString(), "", "");
                    _testTask.Insert(task, -1);
                }
            }

            if (keyInfo.isZTCClick() == false)
            {
                task = new TaskInfo(((int)TaskCommand.Task_ClickMe).ToString(), keyInfo.m_zrWangwangName, "", ((int)ElementTag.outerText).ToString(), "");
                _testTask.Insert(task, -1);
            }
            else
            {
                task = new TaskInfo(((int)TaskCommand.Task_ClickLink).ToString(), keyInfo.m_ztcTitle, "", ((int)ElementTag.title).ToString(), "");
                _testTask.Insert(task, -1);
            }

            int visitMainPage = rndGenerator.Next(getMainItemMinTime(), getMainItemMaxTime());
            task = new TaskInfo(((int)TaskCommand.Task_VisitPage).ToString(), visitMainPage.ToString(), "", "", "");
            _testTask.Insert(task, -1);

            int enterMainIndex = rndGenerator.Next(0, m_clickMainPageItem.Length);
            task = new TaskInfo(((int)TaskCommand.Task_ClickLink).ToString(), m_clickMainPageItem[enterMainIndex].ToString(),
                "", ((int)ElementTag.outerText).ToString(), "");
            _testTask.Insert(task, -1);

            int pageVisitDeep = getVisitDeep();
            if (visitDeepRndCheckBox.Checked)
            {
                pageVisitDeep = rndGenerator.Next(1, 5);
            }

            for (int i = 0; i < pageVisitDeep; i++)
            {
                int rndVisitTime = rndGenerator.Next(getOtherItemMinTime(), getOtherItemMaxTime());
                task = new TaskInfo(((int)TaskCommand.Task_ClickCompare).ToString(), "http://detail.tmall.com/item.htm", "http://item.taobao.com/item.htm", "", "");
                _testTask.Insert(task, -1);
                task = new TaskInfo(((int)TaskCommand.Task_VisitPage).ToString(), rndVisitTime.ToString(), "", "", "");
                _testTask.Insert(task, -1);
            }

            return true;
        }