Reading HTML Code From a Website in LabVIEW

Updated Jan 5, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Operating System

  • Windows

Issue Details

I would like to use LabVIEW to read raw HTML data from a website. What functions are available in LabVIEW to accomplish this?

Solution

You can read raw HTML data from a website using the DataSocket VIs within LabVIEW. These VIs are located in the functions palette under Data Communications»DataSocket. Follow the steps below to read the entire HTML source code from a specific website. A small example image of the completed code is displayed below the following steps. 
  1. Right-click on the block diagram, and select Data Communications»DataSocket»DataSocket Open. Wire a string with the website address into the URL input. Create a constant or control to wire into the Mode terminal by right clicking on the terminal and selecting Create»Constant or Create»Control. Select the input mode as desired (Read will work for simply inputting data from the website). 
  2. Select the DataSocket Read function on the controls palette by navigating to Data Communications»DataSocket»DataSocket Read. Wire the Connection ID from the DataSocket Open VI to the Connection In terminal on the DataSocket Read VI. Next, create an empty string constant by right-clicking on the block diagram and selecting String»String Constant. Wire the newly created string constant into the type (Variant) input terminal on the DataSocket Read VI.
  3. Place the DataSocket Close function on the block diagram by selecting Data Communications»DataSocket»DataSocket Close from the functions palette. Wire the Connection Out from the DataSocket Read VI to the Connection ID terminal on the DataSocket Close VI. In addition, connect the error clusters between the three DataSocket VIs.
  4. The data output of the DataSocket Read VI should output a string datatype and this is where the HTML data will be displayed. 

Additional Information

Use the functions on the String palette to parse the HTML code and extract useful data. One function that is useful for doing this is String»Match Pattern.

WAS THIS ARTICLE HELPFUL?

Not Helpful