Custom VBScript Code - Access web pages within a script (kb2650)
The information in this article applies to:
- SwyxWare from version 4
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.
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.
The function dollar()must be written in the Start-Block of your GSE-Script in the field "User Script" in the TAB "Parameters":
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
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:
For simply calling a webpage without evaluating its content, you can also use the following function which is provided in the Swyx Forum:
- Swyx Forum - GSE build in functions
This Swyx Forum article documents the GSE build in functions.
- Swyx Forum - Server Script API
This Swyx Forum article documents the SwyxServer Script API.
- Swyx Forum - VBScript functions
This Swyx Forum article documents all VBScript build in functions.
The third-party contact information included in this article is provided to help you find the technical support you need. This contact information is subject to change without notice. Swyx in no way guarantees the accuracy of this third-party contact information nor is responsible for it's content.