Retrive Information from a Webpage

May 30, 2013 at 9:59 PM
It's possible pull information from a website?

For example i have my webpage on www.example.com/webpage.php, the webpage contain a query to pull information from a Database and the result will be as...

Total of Jobs in Queue: 3
Jobs Finished: 3

Where the Bold numbers are the results of the query and I want to pull that information to the Gadget.
Jun 8, 2013 at 9:53 AM
Edited Jun 8, 2013 at 9:57 AM
Hello. Thank you for using Gadget Creator. You can use Microsoft.XmlHttp to get information from pages. Here is the example code(in VBScript) how to get information from XML, if you are using PHP - there is no problems. Here is the code:
Sub GetSomeInfo
    Set objXML = CreateObject("Microsoft.XmlHttp")
    objXML.Open "GET", "http://example.com/webpage.php", True
    objXML.OnReadyStateChange = GetRef("objXML_onreadystatechange")
    objXML.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
    objXML.Send
    iTimeoutID = window.SetTimeout("mySleep", 1000)
End Sub

Sub mySleep
  if bRespReceived = "false" then
    iTimeout = iTimeout + 1
    if (iTimeout > 30) then  'timeout
       timerFirstRun = window.SetTimeout("Update", 60000) 'try to update in minute
    else
      iTimeoutID = window.SetTimeout("mySleep", 1000)
    end if
   end if
End Sub

Function objXML_onreadystatechange()
  If (objXML.readyState = 4) Then
    'msgbox objXML.statusText
    If (objXML.status = 200) Then
      bRespReceived=true
      SaveFile(objXML.responseText)
    else 
      timerFirstRun = window.SetTimeout("Update", 60000) ' try to update in minute
    End If
  End If
End Function

Function SaveFile(what)
  Set fso = CreateObject("Scripting.FileSystemObject")
  tempFolder = fso.GetSpecialFolder(2)
  filepath = tempFolder+"\weather.xml"
  Dim fso1, tf
  Set fso1 = CreateObject("Scripting.FileSystemObject")
  Set tf = fso1.CreateTextFile(filepath, True, True)  'rewrite, unicode
  tf.Write(what) 
  tf.Close
  ParseXML
End Function
You can use JavaScript instead, but it's easier to use VBScript in this case. Sorry for my bad English. Have a nice day!