HTML Question

Saturday, December 23, 2006 by jlaj1989 | Discussion: DesktopX

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
sViz
Reply #1 Sunday, December 24, 2006 2:27 AM
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.
jlaj1989
Reply #2 Sunday, December 24, 2006 10:42 AM
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?
rabidrobot
Reply #3 Sunday, December 24, 2006 1:38 PM
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.
sViz
Reply #4 Sunday, December 24, 2006 6:09 PM
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.
sViz
Reply #5 Sunday, December 24, 2006 6:18 PM
*slaps forehead*

If forgot the quotations around "Get".    Will get back to you.
jlaj1989
Reply #6 Sunday, December 24, 2006 6:37 PM
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.
sViz
Reply #7 Sunday, December 24, 2006 6:42 PM
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)
jlaj1989
Reply #8 Sunday, December 24, 2006 7:38 PM
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.
rabidrobot
Reply #9 Sunday, December 24, 2006 11:53 PM
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.
sViz
Reply #10 Monday, December 25, 2006 5:21 AM
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.
jlaj1989
Reply #11 Monday, December 25, 2006 11:07 AM
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.
sViz
Reply #12 Monday, December 25, 2006 6:36 PM
No problem. Good luck.  

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01