How to get text inside div tag in VB.NET -
i made program notify me if game server offline or online think there's simple version of program. btw. website associated in project
http://stats.teamextrememc.com/iframe_status.php
it returns n of 150 players, (online)wait, , offline displayed in page , in title. know how title of web document using document.title
need number of players(n) not "of 150 players" , want play sound file if server online or offline(if server online, page returns "n of 150 players" (online)wait considered offline)
this code:
public class form1 private stat string private time integer private doctitle string private onetime boolean = false public sub playsoundfile(byval soundpath string) playsound.soundlocation = soundpath playsound.load() playsound.play() end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load refresher.start() end sub private playsound new system.media.soundplayer private sub timer1_tick(byval sender system.object, byval e system.eventargs) handles refresher.tick doctitle = browser.documenttitle time += 1 label1.text = doctitle if time = 5 browser.refresh() time = 0 end if if doctitle = "offline" , onetime = false playsoundfile("c:/down.wav") onetime = true elseif doctitle <> "offline" , onetime = true playsoundfile("c:/up.wav") onetime = false end if end sub private sub label1_click(byval sender system.object, byval e system.eventargs) handles label1.click end sub end class
and page returns when open in browser:
<!doctype html><html> <head> <title>150 of 150 players</title> <meta http-equiv="refresh" content="20"> <style> body { margin:0; padding:0; background-color:transparent; color:#66ff00; font-family: verdana,geneva,sans-serif; font-size: 13px; } #statuserr {color:#ff3636} .white { color: #eee; font-size:11px } .dark { background-color:#333; font-size:24px } </style> </head> <body class=""> <div class="">150 of 150 players<br/></div> </body>
if html simple, should able call `document.body.innertext' or 'document.documentelement.textcontent', depending on engine 'browser' object uses.
if site yours, may want adjust php return json or xml instead of html. (xml has bonus of letting specify stylesheet, same url can work in both browser , program query.)
Comments
Post a Comment