Example Code

Webpage Search & Notification Tool

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

 

Overview
This code allows the user to periodically search a webpage for a specific string such as "LabVIEW" and send an email notification if the string is found. One potential application would be generating an email notification when a product becomes available for purchase on a web page. The application can be minimized and left to run unattended.


Description
The program works by first retrieving the HTML code from a specified webpage using the DataSocket VIs contained in the Data Communication palette. The source HTML is then searched for a user specified string using the "Match Regular Expression" VI. If the string is found, the "Match Regular Expression" VI outputs the string. If it is not found, the output will be an empty string. The program then checks the output string and determines whether it is empty to indicate whether the string was present on the webpage. The frequency of webpage queries can be specified by the user in seconds.

Based on whether the string is found, the program can send a notification email using the SMTP Client VIs.The SMTP configuration requires a server (such as smtp.gmail.com), user login information (such as a gmail login), a from email address, an email recipient, a subject line, and a message. For certain email servers, such as gmail, TLS/SSL is required and should be checked. The program will automatically stop running when an email is sent.

 
Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download and Open the VI
  2. Specify webpage URL and string to find
  3. Specify SMTP email settings
  4. Run the VI

Additional Information or References
You should change other E-mail server if error 1172 occurred when using Gmail, because the Gmail SMTP server requires a secure connection or the client was not authenticated.

VI Block Diagram

 5-327.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Rob B
FlexRIO Product Manager

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.