Wednesday, July 6, 2011

Using Proxy With WebClient

Here is a snippet to use WebProxy. This is useful for scraping or other webrequest activities.
   1:    Dim webclient As New System.Net.WebClient  
   2:    Try  
   3:     'true for bypassOnLocal  
   4:     webclient .Proxy =   
   5:          New System.Net.WebProxy("180.95.129.232:80",true)  
   6:     wc.OpenRead("http://yoursite.com")  
   7:     lblStatus.Text = "ok"   
   8:    Catch  
   9:     lblStatus.Text = "error proxy"  
  10:    End Try  

1 comments:

  1. when I'm using a list of proxy
    xxx.xxx.xxx.xxx:xxxx
    xxx.xxx.xxx.xxx:xxxx
    xxx.xxx.xxx.xxx:xxxx
    xxx.xxx.xxx.xxx:xxxx
    ...
    ...

    - only first proxy returns "ok"
    other items in this list are not working.

    ReplyDelete