How to Read Text from Browser Main Window
Keywords: httpRecvText
Question:
I am trying to find out how to use WinBatch to poll my browser's main window for certain text strings (and make decisions accordingly). I would greatly appreciate any suggestions and/or sample code that anyone could provide, neither the control manager extender or the internet extender seem to support this directly.Answer:
Although WinBatch (with work) could possibly read the Browser window, it could read the webpage itself using the WinBatch Internet Extender HttpRecvText function, and scan the data without getting a Browser involved at all. It all depends on exactly what you need to do.This seems to do the trick. An example below:
AddExtender("WWWSK34I.DLL") URL="http://www.yourdomain.com/" serv=httpGetServer(URl, "") path=httpGetpath(URl, "") a=httpRecvText(serv, path, 500, 0) b=StrIndex(a,"[title]",1,@FWDSCAN) if b == 0 b=StrIndex(a,"[TITLE]",1,@FWDSCAN) endif c=StrIndex(a,"[/title]",1,@FWDSCAN) if c == 0 c=StrIndex(a,"[/TITLE]",1,@FWDSCAN) endif if b == 0 || c == 0 message ("Bad HTML","cannot parse title tags") else message("Got the title!",StrSub(a,b+7,c-b-7)) endif
Article ID: W12664Filename: Read Text from Browser Window using httpRecvText.txt