A lot of people use wrappers for grabbing website code, which is rather useless in my opinion since their main purpose is for getting and posting specific data. A webclient resembles the Inet control in VB6, except that it can only be instanciated, or declared and not placed as an object on a form. It's a member of the System.Net library, so if you do use it, you'll need to import that library or add the proper prefix when declaring it. Examples: Code (Text): Imports System.Net Code (Text): Dim Client As New System.Net.WebClient The webclient has several useful classes, but for now you will most likely only need the DownloadString class. It has a single property and returns a string, which will be the source code of the property (a URL) that you defined. An example would be: Code (Text): Dim strPage As String = Client.DownloadString("http://www.neopets.com/") Using the said source code of the webpage, you can proceed to use Mid functions (or GetBetween()) to find what you need, or simply InStr if your needs are less complex. This is a quick and easy solution to grab webpages and parse through them. I hope this helped some people out
Does the webclient handle cookie ? As far as I know, it's usefull only for simple task. edit: found what I was looking for (system.net.cookiecontainer)
so are you saying that this would be a better way to make programs, with this WebClient rather than a wrapper, or are you just offering it as an alternative?
I see it as an alternative. The wrapper was made to handle all the crap for you. It will store the cookies, handle them, change the headers of the connection to receive images, etc... I'm pretty sure you can do all this using the webclient and other system.net class, but you need to handle all this by yourself.
Wrappers > webclients But why copy and pasta/create your own wrapper when you can do a single declaration and effectively do a simple task with as much performance? It's a little dumb to me to use a wrapper for basics, like grabbing page code...Doing something like that with wrappers only makes the size of the application bigger. So yea, an alternative for simple tasks I guess ^_^
Yeah, for a simple task, you can use this. But as soon as you need to login to a site, better use the wrapper.