예제 #1
0
    public ProxyManager(string[] proxies)
    {
        SEOWebRequest.Init();
            WebProxy proxyBuffer;
            foreach(string s in proxies)
            {
                string[] data = s.Split(':');
                proxyBuffer = new WebProxy(data[0], Int32.Parse(data[1]));
                if(data.Length==4)
                {
                    proxyBuffer.UseDefaultCredentials=false;
                    proxyBuffer.Credentials = new NetworkCredential(data[2], data[3]);
                }
                proxiesList.Add(proxyBuffer);
            }

            foreach(WebProxy proxy in proxiesList)
            {

                new Thread(() =>
                {
                    SEOWebRequest req = new SEOWebRequest();
                    string s = req.GET("http://www.google.com", proxy);
                    if (req.LastOK)
                    {
                        workingProxiesList.Add(proxy);
                    }
                    IncreaseCount();
                }).Start();
            }
    }
예제 #2
0
        private void checkBacklinks_Click(object sender, EventArgs e)
        {
            if (work == null)
            {
                work = new WorkManager(backlinksList);
            }
            if(work.active)
            {
                work.active = false;
                checkBacklinks.Text = "Check Backlinks";
                work = new WorkManager(backlinksList);
                return;
            }
            new Thread(() =>
            {
                if (backlinksList.Count > 0)
                {
                    if (backlinksList.Count < (int)threadCount.Value)
                    {
                        threadCount.Value = backlinksList.Count;
                    }

                    for (int i = 0; i != threadCount.Value ; i++)
                    {
                        int threadID = i;
                        new Thread(() =>
                        {
                            Log.SetActiveThreadCount(true);

                            SEOWebRequest threadReq = new SEOWebRequest();
                            while (work.Working)
                            {
                                lock (new object())
                                {
                                    if (!work.active)
                                    {
                                        Log.SetActiveThreadCount(false);
                                        return;
                                    }
                                    string s = work.GetWork;
                                    if (s != null)
                                    {
                                        string source = string.Empty;
                                        if (useProxies)
                                        {
                                            source=threadReq.GET(MakeQuery(s),proxyManager.WorkingProxy);
                                        }
                                        else
                                        {
                                            source = threadReq.GET(MakeQuery(s));
                                        }
                                        if (source != null)
                                        {

                                            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                                            doc.LoadHtml(source);
                                            HtmlNodeCollection searchResults = doc.DocumentNode.SelectNodes("//li[@class='g']");
                                            if (searchResults != null)
                                            {
                                                if (searchResults.Count > 0)
                                                {
                                                    indexedBacklinksList.Add(s);
                                                    Log.IncreaseIndexedCount();

                                                }
                                            }
                                            else
                                            {
                                                not_indexedBacklinksList.Add(s);
                                                Log.IncreaseNotIndexedCount();
                                            }
                                        }
                                        else
                                        {
                                            Log.WriteLog(string.Format("[Thread {0}] {1}", threadID.ToString("0000"), threadReq.LastError));
                                        }
                                    }
                                }
                            }
                            Log.SetActiveThreadCount(false);
                            return;
                        }).Start();
                    }
                    work.active = true;
                    checkBacklinks.Text = "Stop Checking";
                }

                else
                {
                    Log.WriteLog("Please load some backlinks");
                }
            }).Start();
        }