PixieWare Software: Sample Script
Website Design and Data Extract Solutions

By Dave Johnstone

Example VBScript to Search a HTML Page

Sub Main
  ' Product price extract from  http://www.pixieware.com/totprices.htm
  ' This VB Script extracts the price table from the above HTML page. This 
  ' script searches the HTML for the Price data that is found between two 
  ' pre-selected HTML tags: <table> and </table>.

  ' The script statement Monitor=True causes the conversation to be 
  ' made visible. Monitor=True should always be the first line in a new 
  ' Sub Main. Change to Monitor=False when you "go production".
Monitor = True

  ' The script statement Silent=True causes "pup-up boxes" to be ignored. 
Silent = True

  ' Set up the address (URL) to navigate to. This is a PixieRobot function
  ' used for navigation and form submission. The HTML code is returned 
  ' as a string in the variable "s", from where it can be processed.
s = ExecuteWWW("http://www.pixieware.com/totprices.htm")

  ' Find the nominated string embedded in the source HTML of the URL.
  ' The InStr function returns the numeric position of the first occurrence 
  ' of a specified substring within a specified string when starting from 
  ' the beginning (left end) of the string. The string was chosen as it
  ' represents something unique on the Web page and therefor is a good
  ' place on which to focus the search and extract process.
iPos = Instr(1, s, "Prices are subject to change without notice.", 1)

  ' As there are several occurrences of <table> in the HTML but we need to find 
  ' the occurrence immediately following the "Prices are ...." string. 
iPos = Instr(iPos, s, "<table ", 1)

  ' The Mid function returns the portion of the designated string for a 
  ' designated length starting from the position (iPos) in the string. 
s = Mid(s, iPos)

  ' Now find the </table> string following the nominated <table> string.
iPos = Instr(1, s, "</table>", 1)

  ' The Left function returns the left portion of the designated string for 
  ' a designated length. iPos plus the length of </table> (8 characters).
s = Left(s, iPos+8)

  ' Now output the extracted string into the nominated file. The .xls 
  ' file extension will cause MS_Excel to read the extracted HTML and 
  ' format the table (into columns and rows) in the same manner as a browser. 
Call OutputToFile(s, "prices.xls")
End Sub

Discover Our Products and Services


Web-Site Development




About PixieWare Software


Designed and built by: Designed and built by PixieWare Software

Turn your WEB vision into reality!

Let us
a website quote

Website Build Package
Creation of website (maximum 5 pages). Price: CDN$350 per website, $100 of fee due as an up-front downpayment, and $250 of fee due on project completion. Package does not include any additional external fees related to the project (e.g.):

  • Domain-name registration fee (annual fee)
  • Website hosting fee (monthly or annual fee)
  • Email-accounts processing fee (if relevant, a monthly or annual fee)
  • Any other fee related to domain name re-location or change of name server

Turn your WEB vision into reality!