Reading HTML Code From a Website in LabVIEW

Updated Feb 14, 2019

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

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 HTTP VIs within LabVIEW. These VIs are located in the functions palette under Data Communication»Protocols»HTTP Client. Follow the steps below to read the entire HTML source code from a specific website.
  1. Right-click on the block diagram, and select Data Communications»Protocols»HTTP Client»Open Handle
  2. Select the GET function on the functions palette by navigating to Data Communications»Protocols»HTTP Client»GET. Wire the client handle out from the Open Handle VI to the client handle terminal on the GET VI. Next, create an empty string constant or control by right-clicking on the url terminal and selecting Create»Constant or Create»Control. Insert the URL for the website you that contains the HTML code you are trying to retrieve.
  3. Place the Close Handle function on the block diagram by selecting Data Communications»Protocols»HTTP Client»Close Handle from the functions palette. Wire the client handle out from the GET VI to the client handle on the Close Handle VI. In addition, connect the error clusters between the three HTTP VIs.
  4. The body output of the GET VI should output the HTML data from the website. 

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.

If you need to add or change headers to the HTTP request, you can use the Add Header VI located at Data Communications»Protocols»HTTP Client»Headers»Add Header.

WAS THIS ARTICLE HELPFUL?

Not Helpful