HTML Question

Is it posible to pull html from websites into desktop x?  i want to make a widget that shows who is in a game server and who is all joined, they have a adress for all of that so i was wondering if i could pull it off website and put it in desktopx, and have it update.  Thanks
3,956 views 12 replies
Reply #1 Top
Is it posible to pull html from websites into desktop x?


Yes, I think so. I'm no expert but I was fooling around with the source code from this daily factoid site and even though it wasn't formatted to be read like xml I could still pull the information I wanted from the HTML code.

Load up the webpage that you’re trying to get info from and go to your explorer Commands bar > View > Source. If you can view the source code this might work. Take a look at the code and see if you can find the information you want to ‘pull’. Does it have an identifier like a specific html tag or a unique syntax? If so, you should be able to get an rss reader to pull that information. Let me know if this is a start in the right direction.
Reply #2 Top
Yes you can view the source but there is no identifiers its just table and tr mainly. Will a rss reader work for any site? or is it just for xml and rss?
Reply #3 Top
I haven't worked with these personally, they're pretty new I think, but DesktopX has some built in techniques for getting HTML.

Look at the System.SendRequest(remoteUrl, postParams, bAsync) sample from
DX Docs (Scroll to bottom)

There's a sample of how to make the request, and the callback that will have your result.

If you can't use standard XML or RSS style parsing on the received data, there are several options for extracting it, as sViz pointed out.

One frequently useful approach is to use the vbscript Split function. W3Schools
If there are identifying strings around the relevant data, you can split the HTML into an array at those strings. Like if the page displayed the names:
Name: Hooter
Name: Killjoy
Name: Jester

You could Split(WebPageSourceHTML, "Name: ") to get an array of strings. You'll find the names at the beginning of the strings in Array(1-3). You would split these strings themselves by a space to fully extract the name data. Sometimes you'll split more than once. Like split for tables, get the table you want, then split it for some other identifier to isolate the desired info. When using splits, remember that the string in NewArray(0) is the text before the split, and the strings in NewArray(1-n) are strings that come after your chosen delimiter. I'm just saying this is a time where I often forget about the zero momentarily and have to rethink it. Once you get a good parser together, though, you can do a lot with it.

As long as the HTML from your server info presents itself the same way each time, you should be able to use string manipulation vbscript on the 'pagecontent' results from a System.SendRequest to extract any information you want.
Reply #4 Top
Will a rss reader work for any site?


If you manipulate the script it can work for html but you have to have some kind of identifier for the info you want or it won't work. I think Rabidrobot explains it better. I didn't know about system.sendrequest. I tried it like so:

strPage= System.SendRequest("http://www.comcast.net", Get, False)

and kept getting a syntax error. If you can get it to work then using the Split function like Rabidrobot explained is probably the way to go.
Reply #5 Top
*slaps forehead*

If forgot the quotations around "Get".    Will get back to you.
Reply #6 Top
Wow i wish it wasent so complicated i have not a clue how to do any of that. Thanks for your help, some one should make a tutorial or a example.
Reply #7 Top
Okay well, my DX says it doesn't support system.sendrequest so I'll just have to stick to the RSS method.

There is a tutorial on how to make an RSS reader by CerebroJD WWW Link

Took me a while to figure it out but once I got the hang of it I was able to make my very own RSS feeder.(To be released soon)
Reply #8 Top
Ive got this far, WWW Link

Now how can i get the text on the left, in the web page, to the right like i have it there. and so it updates the text from left.
Reply #9 Top
That looks like you got it going just fine. If you want the specific information you'll have to find each bit you are interested in. You can do that like you have been, narrowing down to the important stuff.

Looks great to me, you can use multiple text objects or create a long string with vbTab and vbNewline to emulate a table--once you snip out the key info.

If you want to display all the information, consider styling the table you've already extracted with CSS. It's already well laid out, and the html has class assignments in place.
Reply #10 Top
Yeah, you seem to be much better at scripting than me. After hours of trying to get it just right I came back here and realised that you wanted the WHOLE table of info and not just the info you had in the text object.    Well, I worked out a script for just the info you had in the text object. I had trouble removing unwanted spaces and keeping the spaces you do want. If you check out the object below you'll see how I opted to deal with it. Maybe you'll find this script useful for something.


Okay here's the object with the script: LINK

Like rabidrobot said perhaps you could create a text object for each table of contents and insert a similar script to the one above modified to extract the correct information.
Reply #11 Top
Thanks sViz and rabidrobot for your time. Thats exactly what i was trying to do sViz, thanks, ill mess around and see if i can get rid of spaces and stuff.
Reply #12 Top
No problem. Good luck.