LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if a website exists or not

Hello everyone. I need to check if a website page exists or not. In particular, I would like to check if a URL actually leads to a web page or not, and be able to get an "error404" or something else from the page in real time. I use LabVIEW 2009 and I have no clue how to do that. I've been trying so far with DataSocket, Connectivity tool, and so on... but it just does not seem to work. Do you know how I could manage all of this? 
Thank you. 

0 Kudos
Message 1 of 11
(12,927 Views)

Hi gears,

 

why don't you try to load your webpage using datasocket? You will either get the HTML code or an error indicating a non-existing page...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(12,915 Views)

Use the HTTP GET function, the headers will contain the response code.

 

https.png

 

0xDEAD

0 Kudos
Message 3 of 11
(12,874 Views)

Do you have a HTTP VI library that is compatible with LabView 2009?


@deceased  ha scritto:

Use the HTTP GET function, the headers will contain the response code.

 

https.png

 

0xDEAD


 

0 Kudos
Message 4 of 11
(12,854 Views)

Hello and thank you for your help. I actually have tried this structure in particular, but it seems not to be working. Whether or not the URL exists, the data shown are always the same... so it is impossible for me to get a string from the code given that refers to an existing website. 

I can show you. 

This is what I get although the given URL actually does not exist:
http://pegaso.multiversity.click/main/lp-video_student_view/lesson_student_view.php?lp_id=291&id_les...


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+ARIA 1.0//EN" "http://www.w3.org/WAI/ARIA/schemata/xhtml-aria-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Piattaforma Unipegaso</title> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link type="text/css" href="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/bootstrap/css/bootstrap.css" rel="stylesheet"><link rel="stylesheet" href="https://pegaso.multiversity.click/main/css/dokeos2_pegaso/font/css/font-awesome.min.css" /><link href="https://pegaso.multiversity.click/main/inc/font/font-awesome.4.7.0/css/font-awesome.min.css" rel="stylesheet" /><link href="https://pegaso.multiversity.click/main/css//default.bootstrap.css" rel="stylesheet" /><link href="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/ui/css/custom-theme/jquery-ui-1.10.3..." rel="stylesheet" /><script type="text/javascript" src="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/jquery/jquery.js" language="javascript"></script><script type="text/javascript" src="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/bootstrap/js/bootstrap.min.js" language="javascript"></script><script type="text/javascript" src="https://pegaso.multiversity.click/main/inc/lib/javascript/stickyfooter.js" language="javascript"></script><script type="text/javascript" src="https://pegaso.multiversity.click/main/inc/lib/javascript/dokeos.js.php" language="javascript"></script><script type="text/javascript" src="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/ui/assets/js/vendor/jquery-ui-1.10.3..." language="javascript"></script></head><body><div><div class="logo-login"></div><div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
<img class="logo-image" src="https://pegaso.multiversity.click/main/inc/lib/header-bootstrap/img/logopage.png" style="max-width: 200px; margin:10px;" alt="Logo Pegaso" />
</div>
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">ACCEDI ALLA PIATTAFORMA</div>
<div class="panel-body">
<form class="form-signin" action="" method="post">
<div class="form-group">
<label class="sr-only" for="inputUserName">Username</label>
<input name="login" id="inputUserName" class="form-control" placeholder="Username" required="" autofocus="" type="text" />
</div>
<div class="form-group">
<label class="sr-only" for="inputPassword">Password</label>
<input id="inputPassword" class="form-control" placeholder="Password" required="" name="password" type="password" />
</div>
<div class="form-group">
<button class="btn btn-lg btn-default btn-block" type="submit" style="background-color: #333333; color: #fff;">Entra</button>
<a class="btn btn-lg btn-default btn-block" type="button" href="https://pegaso-accessibile.multiversity.click/login.html">Vai alla versione accessibile</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div></div></body></html>

0 Kudos
Message 5 of 11
(12,853 Views)

I don't have anything as old as 2009 installed.

 

In the version I use they are located in the "Data Communication -> Protocols -> HTTP Client" palette.

 

 

0 Kudos
Message 6 of 11
(12,845 Views)

I've actually found this:
https://forums.ni.com/t5/NI-Labs-Toolkits/LabVIEW-HTTP-Client/ta-p/3500778

I've tried it, but it seems not to be working. It just displays the presumable data of the non-existing website that I ask LabVIEW to check. 
What if I want to detect a general error from a website... like "error400" or "error500"? Do you know how I could arrange such a system?


0 Kudos
Message 7 of 11
(12,843 Views)

@Gears_math wrote:

Hello and thank you for your help. I actually have tried this structure in particular, but it seems not to be working. Whether or not the URL exists, the data shown are always the same... so it is impossible for me to get a string from the code given that refers to an existing website. 

I can show you. 

This is what I get although the given URL actually does not exist:
http://pegaso.multiversity.click/main/lp-video_student_view/lesson_student_view.php?lp_id=291&id_les...

 


That website does exist.  It returns a login page.

0 Kudos
Message 8 of 11
(12,841 Views)

Hello and thank you for your help. Actually, I am logged in to the website. When you are logged in, if the URL exists, you get redirected to an existing page... but if it does not exist, you get an "error500" from the browser. 


You cannot see this because you are not logged in, so you get redirected to the login webpage.
In this website, some videos are contained inside of some kind of folders which are shown in the URL.

This is an example of a URL:
https://pegaso.multiversity.click/main/lp-video_student_view/lesson_student_view.php?lp_id=45&id_les...
in which lp_id=45 is the folder and lesson=241 is the video


If I change the number of the video to a non-existing one I get an "error500" from the browser which unfortunately I cannot detect, at least with the system I've build-up. 

Any suggestion? Thank you.

0 Kudos
Message 9 of 11
(12,837 Views)

I just tried with the HTTP example I posted I get the following header returned and no body.

 

 

HTTP/1.1 302 Found
Date: Wed, 02 Jan 2019 15:41:35 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
Server: Apache/2.4.29 (Ubuntu)
X-Powered-By: PHP/5.6.38-3+ubuntu18.04.1+deb.sury.org+1
Set-Cookie: dk_sid=0d016a687ee315e4e126706875b990f5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: https://pegaso.multiversity.click/
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE

 

0xDEAD

0 Kudos
Message 10 of 11
(12,824 Views)