From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to enter in a web page with LabView?

Hello everyone,

 

I´ve been thinking in a project but I don´t know hot to do it...

Let me explain my project idea: I love chess, I am an mechatronic student and I like too much Labview programming, I want to make all this togueter in a single project.

In internet there are web pages where you can play in a modality called *correspondence*, I mean you start to play with somebody he sends you his move and you have all one day to reply the move.

And I want to make a chess that moves for himself when my opponent sends his move then I would make my move and it would be automatically send to my opponent.

And my question is... Is there any way to enter as a client in a web page, read some part of the web page and then send a reply with Labview? Do I have to use other programming Language? Is not posible what I want to do?

In the chess web I want to log in with an user and a password

 

Hope you can help me

Alhebu

 

Here is the page I want to read

https://lichess.org/

1. d4 d5 2. c4 c6 3. cxd5 cxd5 4. Nf3 Nf6 { D13 Slav Defense: Exchange Variation } 5. Nc3 Bg4 6. Ne5 e6 7. Qb3 Nc6 8. Nxg4 Nxg4 9. h3 Nf6 10. Bg5 Be7 11. e3 O-O 12. Bd3 Rc8 13. Rc1 e5 14. Bxf6 Bxf6 15. Nxd5 exd4 16. Nxf6+ Qxf6 17. O-O dxe3 18. fxe3 Qg5 19. Rce1 b6 20. Qa4 Ne5 21. Bc2 Rfd8 22. Qe4 g6 23. h4 Qh5 24. Bd1 Rxd1 25. Rxd1 f5 { Black resigns. } 1-0

 

This is an example of how the moves are readed by humans

0 Kudos
Message 1 of 4
(2,365 Views)

Hey Alhebu,

 

Sounds like an interesting project. I think it will come down to how the website is built and what they expose for you to send and receive moves.

 

You could try using HTTP methods if the website has an API to send and receive commands using GET/POST requests. However, the link you posted seems to rely in code that runs in the browser (apparently a high amount of JavaScript code), which makes it difficult to control from a language such as LabVIEW.

 

You could also consider an integration with a .NET, Python or ActiveX component to handle the communication in between the website and the LabVIEW code. Nevertheless, this would be a tedious process and will involve utilizing more than just LabVIEW to make it happen.

 

In short, while LabVIEW is an environment that provides many advantages, I don't think this application would be its best use case. I recommend you explore other options before going down this path.

 

All the best,

Message 2 of 4
(2,285 Views)

Hello!

As @oscarfonseca states, interfacing with dynamic web pages might be the biggest step in this project. However, if You figure out how to do it in LabVIEW, You may find customers wanting to buy your solution 😉

 

Still, it seemd that You are lucky in choosing chess as Your subject: The site can probably provide you with the state of the game in this human-readable format:

 


@alhebu wrote:

 

1. d4 d5 2. c4 c6 3. cxd5 cxd5 4. Nf3 Nf6 { D13 Slav Defense: Exchange Variation } 5. Nc3 Bg4 6. Ne5 e6 7. Qb3 Nc6 8. Nxg4 Nxg4 9. h3 Nf6 10. Bg5 Be7 11. e3 O-O 12. Bd3 Rc8 13. Rc1 e5 14. Bxf6 Bxf6 15. Nxd5 exd4 16. Nxf6+ Qxf6 17. O-O dxe3 18. fxe3 Qg5 19. Rce1 b6 20. Qa4 Ne5 21. Bc2 Rfd8 22. Qe4 g6 23. h4 Qh5 24. Bd1 Rxd1 25. Rxd1 f5 { Black resigns. } 1-0

 

This is an example of how the moves are readed by humans


So, as a first and probaly more feasible step, You could design a chess board VI that receives the list of moves. From this list, it could then re-create the state of the chess board.

 

Then the next step would be to figure out how the web-page receives the next move. If You find it hard to interface with the API of the website, You could take a shortcut by just simulating mouse actions inside the browser window. There are some standalone tools that can do that for you, I guess there might be quite a selection of tools working with the Call Library node or System Exec node - search for "Simulating Mouse Clicks".

 

In the end, Your project sounds very nice, but also quite huge and there are is quite a range of possile approaches and partial tasks. I would recommend focussing on the LabVIEW part first and working on the interface later.

0 Kudos
Message 3 of 4
(2,274 Views)

Another alternative is to see if the service you are trying to access has an API.

 

 

chesstoken.PNG

 

  • I created an API token for permissions I was interested in. In this case just "Read email address" to test the api
  • In the docs I found an API I was interested in. In this case I used the Get my email address API and in the docs took not of the HTTP Method used (GET), the URL for the API from clicking the URL in the page (https://lichess.org/api/account/email), and the headers I need (Content-type: application/json)
 

apiendpoint.PNG

  • And create a VI capable of making the request

lichess.png

 

In the above VI note that I added a header for Content-Type: application/json as described by the docs, that the <my personal token> should be replaced with the personal API access token that was previously created and that I used Unflatten From JSON to parse the JSON response.

 


Milan
Message 4 of 4
(2,205 Views)