Announcement

Collapse
No announcement yet.

Gặp vấn đề với Google và Proxy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [C#] Gặp vấn đề với Google và Proxy

    Em dùng chương trình c# truy vấn dữ liệu từ google. Truy vấn được khoảng 300 lần thì Server google chặn. Em đã thử đổi proxy nhưng không được.
    Đoạn code lấy dữ liệu từ google và đổi proxy:
    Code:
                string str;
                if (!string.IsNullOrEmpty(keyword))
                {
                    string url = "http://www.google.com.vn/search?num=1&q=" + keyword.Replace(" ", "+") + "&aq=f&aqi=&aql=f&ie=UTF-8&btnG=Search";
                    try
                    {
                        //string url = "http://www.google.com.vn/search?num=1&q=" + keyword.Replace(" ", "+") + "&aq=f&aqi=&aql=f&ie=UTF-8&btnG=Search";
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                        request.KeepAlive = false;
                        request.UserAgent = "Mozilla/11.0";
                        request.Method = "GET";
                        request.ContentType = "text/html";
                        request.Timeout = 30000;
    
                        if (!string.IsNullOrEmpty(strProxy) && int.Parse(strProxy.Split(':')[1]) != 0)
                        {
                            string address = strProxy.Split(':')[0];
                            int port = int.Parse(strProxy.Split(':')[1]);
                            WebProxy myProxy = new WebProxy(address, port);
                            myProxy.BypassProxyOnLocal = false;
                            request.Proxy = myProxy;
                        }
                        //WebProxy myproxy = new WebProxy("31.172.30.3", 443);
                        //myproxy.BypassProxyOnLocal = false;
                        //request.Proxy = myproxy;
                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            str = reader.ReadToEnd();
    
                        }
                        response.Close();
    
                    }
                    catch (Exception e)
                    {
                        
                            Console.WriteLine("Proxy:{0}\t{1}", strProxy, e.Message);
                            strProxy = gIP.GetProxyFromHideMyAss(); // Ham lay proxy moi
                            return -1;
                        
    
                    }
            }
    Kết quả trả về:

    Mong các cao thủ giúp đỡ.
    Last edited by 07520247; 20-04-2012, 16:21.

  • #2
    Nếu liên tục request lên Google thì nó sẽ bắt bạn nhập captcha để xác định là người dùng chứ ko phải bot.
    Chỉ có cách duy nhất là lấy mã captch và gửi lại cho nó.
    Còn việc đổi proxy, IP để qua mặt Google cũng là 1 cách nhưng mình ko biết!
    quần áo trẻ em | quan ao tre em | quần áo sơ sinh | quần áo bé trai | quần áo bé gái | bodysuit carter

    Comment


    • #3
      Em cũng ko rành lắm nhưng google có cũng cấp API cho developer phát triển ứng dụng cho nó.

      Comment

      LHQC

      Collapse
      Working...
      X