예제 #1
0
파일: Form1.cs 프로젝트: VTS2018/GetHTML
        //单个查询的回调函数
        public void CallbackFuction(IAsyncResult result)
        {
            int    num       = 0;
            string strResult = string.Empty;
            string temp      = string.Empty;

            GetWebClientHandler handler = (GetWebClientHandler)((AsyncResult)result).AsyncDelegate;

            string[] html = handler.EndInvoke(result);

            //处理返回的结果
            if (html[0] == "false")
            {
                this.txtResult.AppendText("\r\nIP被封!\r\n");
                return;
            }
            temp = Tools.Google_getProductNum(html[1]);

            num = (temp == string.Empty ? 0 : Convert.ToInt32(temp));

            if (num == 0)
            {
                strResult = "没有收录";
            }
            else
            {
                strResult = num.ToString();
            }

            this.txtResult.AppendText("结果:\r\t" + strResult + Environment.NewLine);
            this.txtResult.AppendText(result.AsyncState.ToString());
        }
예제 #2
0
파일: Form1.cs 프로젝트: VTS2018/GetHTML
        //查询排名情况
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (this.comkeyWords.Text == "")
            {
                return;
            }

            GetWebClientHandler handler = new GetWebClientHandler(HtmlOpear.GetWebClient);

            //需要对关键字进行处理 但是URL却不需要处理
            IAsyncResult result = handler.BeginInvoke(GetStrURI(this.comkeyWords.Text), new AsyncCallback(CallbackFuctionGrankings), "ok");

            this.txtResult.Text = "";
            this.txtResult.AppendText("正在查询中请稍后···\r\n");
            this.txtResult.AppendText("域名:" + this.comDomainItems.Text + "关键词:" + this.comkeyWords.Text + "\r\n");
        }
예제 #3
0
파일: Form1.cs 프로젝트: VTS2018/GetHTML
        //单个查询
        private void btnCurrentSearch_Click(object sender, EventArgs e)
        {
            //使用异步回调的方式实现
            if (this.comkeyWords.Text == "")
            {
                return;
            }

            GetWebClientHandler handler = new GetWebClientHandler(HtmlOpear.GetWebClient);

            //需要对关键字进行处理 但是URL却不需要处理
            IAsyncResult result = handler.BeginInvoke(GetStrURI(this.comkeyWords.Text), new AsyncCallback(CallbackFuction), "ok");

            this.txtResult.Text = "";
            this.txtResult.AppendText("正在查询中请稍后···\n");
            this.txtResult.AppendText(this.comkeyWords.Text + "\t");
        }
예제 #4
0
파일: Form1.cs 프로젝트: VTS2018/GetHTML
        //排名回调
        public void CallbackFuctionGrankings(IAsyncResult result)
        {
            string strResult = string.Empty;

            string[]            html    = null;
            GetWebClientHandler handler = (GetWebClientHandler)((AsyncResult)result).AsyncDelegate;

            html = handler.EndInvoke(result);

            if (html[0] == "false")
            {
                this.txtResult.AppendText("\r\nIP已经被封掉了\r\n");
                return;
            }

            List <string> alist = GetUrlList(html[1]);//代码中已经转换为小写了

            int ranknum = 0;

            strResult = Computingrankings(alist, this.comDomainItems.Text, out ranknum);
            this.txtResult.AppendText(strResult);
        }