Proxy Support

Discussion in 'Visual Basic .NET' started by Fadi946, Nov 21, 2011.

  1. Fadi946

    Fadi946 Power Member

    Joined:
    Mar 25, 2009
    Messages:
    531
    Likes Received:
    77
    Location:
    With my parents :(
    Hi, so I'm done making a bot, but I need to make a proxy support on it so it can be perfect.
    What I mean is, that I put a proxy list (from a .txt file) and it will automatically changes after doing a certain thing.
    I really got no idea how to do this.
    Can anyone please help?
    Thanks.
     
  2. christoss1959

    christoss1959 Senior Member

    Joined:
    Nov 25, 2010
    Messages:
    894
    Likes Received:
    1,153
    First off. You would need to load up the list.
    Proxy lists are usually in the form
    yourproxyServer:yourProxyPort
    So basically you can load up the text file one line each time look for the ":" and separate the two.

    Then you need to define a proxy.
    Dim proxyserver as string="19.168.0.1"
    Dim proxyport as integer=80

    Dim tempProxy As New System.Net.WebProxy(proxyserver, proxyport)

    This webproxy can be used with both the HTTPWEBREQUEST methods and WebClient.

    For the webrequest:
    Dim request As WebRequest = HttpWebRequest.Create(url)
    request.Timeout = 1000
    request.Proxy = tempProxy
    Dim response As WebResponse = request.GetResponse()

    For the webclient:
    Dim client As New WebClient
    client.Proxy = tempProxy
    Dim htmlsource=client.DownloadString(url)


    Hope this makes sense.
     
    • Thanks Thanks x 3
  3. Fadi946

    Fadi946 Power Member

    Joined:
    Mar 25, 2009
    Messages:
    531
    Likes Received:
    77
    Location:
    With my parents :(
    Thanks so much, I've done something similar to this and it works, but not so sure if it REALLY works..
    So basically I went to "www.WhatIsMyIP.com" using VB's webbrowser1, and I see that the IP is really changing.. but when I go to internet explorer (manually, not from VB), I go to whatismyip dot come and I see my real IP there...
    So I don't know, does it work or not?

    My code is this:
    Edit: Nevermind, deleted the code.. It works great, thanks :)
     
    Last edited: Nov 22, 2011
  4. christoss1959

    christoss1959 Senior Member

    Joined:
    Nov 25, 2010
    Messages:
    894
    Likes Received:
    1,153
    I wouldn't suggest using the webbrowser control unless you absolutely have to use it, the webclient and webrequest are much better and can be multithreaded.
     
    • Thanks Thanks x 1
  5. captchaman

    captchaman Junior Member

    Joined:
    Sep 16, 2010
    Messages:
    190
    Likes Received:
    843
    Occupation:
    Software Programmer
    Location:
    USA
    Yeah, christoss1959 is right.. Using the webbrowser is extremely slow and there's not a whole lot you can do with it.

    Here's a good httpwebrequest example to learn from: http://www.808.dk/?code-vbnet-httpwebrequest

    Also to split the proxies, it would be strProxy.Split(":"c)(0) - that's for the IP, (1) is for the port.

    I have a heavily modified httpwebrequest function that handles invalid SSL certs and private proxies and such, PM me if you want it.

    CM
     
    • Thanks Thanks x 1
  6. Fadi946

    Fadi946 Power Member

    Joined:
    Mar 25, 2009
    Messages:
    531
    Likes Received:
    77
    Location:
    With my parents :(
    Thanks for both of you, really helpful information... I've never heard of the webrequest thing, and it sounds so much better.. Because sometimes I just feel limited with the webBrowser.
    I will take a lot at your link and will see how things will go.
     
  7. jaggs

    jaggs Registered Member

    Joined:
    Jun 4, 2009
    Messages:
    70
    Likes Received:
    9
    U can also check out the chilkat component for vb.net applications.Thou its little buggy but still is useful.
     
  8. messsy

    messsy Newbie

    Joined:
    Feb 6, 2012
    Messages:
    1
    Likes Received:
    0
    i would like to see this if possible, thanks