Accessing Contents of Web Page

Can anyone provide or point me to a simple example of how to retrieve the source of a web page into a string using the Xojo.Net.HTTPSocket?

Previously, I successfully used an old socket method to read a web page into a string and then used regex to extract some basic information. Recently, that method became unable to place the source into the string (length was zero after the socket page received had activated) even though the url continued to display when I sent it to an html viewer instead. Although I am not sure, I suspect that the site now requires http 1.1. It may also be the case that site is using a more modern one page format.

In any case, I can’t seem to get my head around the correct way to use Xojo.Net.HTTPSocket, which I need to learn regardless of whether it will resolve my current problem.

Thanks.

Drag a “Generic Object” control onto your Window and change its super to “Xojo.Net.HTTPSocket” and its name to “MySocket”.

Send your request:

MySocket.Send("GET", "http://www.mysite.com")

In the PageReceived event handler for MySocket, convert the data to Text:

' Convert the content receeved from a MemoryBlock to Text. Dim pageData As Text pageData = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(content)

Thanks Paul. I learned some things and your sample helped resolve the problem.