Swyx Knowledgebase

HOWTO: Custom VBScript Code - Access web pages within a script (kb2650)

The information in this article applies to:

  • SwyxWare from version 4

[ Summary | Information ]


Summary

Using some VBScript statements it is possible to access information from a website. In this example a website from Yahoo is checked for each incomming call and the latest Exchange rate Dollar-Euro is retrieved. Then this information is announced.


Information

Access web pages within a script

Microsoft offers a modul called "Msxml2.ServerXMLHTTP.3.0". It gives an easy access to web pages. "Msxml2.ServerXMLHTTP.3.0" is contained in Windows 2000, 2003 and XP, there is no need for a separate installation. You will find detailed informations at Microsoft in the MSDN, in detail the Open Method, used in this example, can be found at:

The function dollar()must be written in the Start-Block of your GSE-Script in the field "User Script" in the TAB "Parameters":

 

  1. Function dollar()
  2.     Dim http_req, pos
  3.     http_req = CreateObject("Msxml2.ServerXMLHTTP.3.0")
  4.     http_req.open("GET", "http://de.finance.yahoo.com/q?s=EURUSD=X&d=0b", False)
  5.     http_req.send()
  6.     pos = instr(http_req.responseText, "Letzter Kurs")
  7.     dollar = mid(http_req.responseText, pos + 54, 6)
  8. End Function

 

This function opens the appropriate webpage of Yahoo, which contains the latest exchange rate between Dollar and Euro. The complete webpage can be found after the send method in the variable http_req.responseText. After extracting the exchange rate, it will be assinged to the return value of the function.

Using this function can be done for example in a Block "Say Number" by entering

=dollar()

in the field "String of digits" at the parameters of the block. The annuncemen will just say the digits, not the decimal point, e.g. 1.2056 will be announced as 1 2 0 5 6.

 

Hint 1: There are more examples of VB Script Code at:

Hint 2: If you use a HTTP proxy server in your network, please ensure that the user account used by the SwyxWare server service to log on, has the appropriate HTTP proxy settings. Otherwise HTTP request will fail with an error message.

This can be configured with the Microsoft Tool PROXY.CFG. Details can be found at:


Comment

Comment on this article



If we have any follow-up questions, where can we contact you?

E-Mail Address (optional)


Note

This feedback form can't be used for support requests. Those requests must be directed to your Swyx reseller or distributor.


Updates

Created: 02.06.2004


  • 15.09.2004: Usage of the server component from Microsoft insteat of the client component to access the web pages.
  • 20.09.2004: Fixed links to Microsoft webpages.
  • 23.09.2004: Link to Microsoft website updated.
  • 23.08.2006: Updated link to Yahoo finance page.