How to: login, navigate, GET html, find in string

#1

Hello, I'm trying to create a flow in which I

  1. inject an hourly request to a HTTP node
  2. which logs in onto a web page,
  3. afterwards navigate to a different page on that website using a URL (which requires being logged in first),
  4. GET all the html code
  5. Convert it to a string
  6. find the word 'connected' in this string
  7. have a debug message with a bool showing if 'connected' was found or not
  8. I can link this to an email notification via smtp later, with an existing and configured email node

I tried experimenting with a HTML node that searches for a specific CSS selector but in all cases it couldn't find it or it returned an empty array while it certainly is not.

Any help or example flows on this would be helpful. I need to add this flow to the existing ones which where set up by someone who left the project team and I am new to Node-RED.

#2

add a debug to the http nodes and set it to display all. Check that you are actually receiving the data you think you are.

#3

I receive the full page in HTML, I have no issues with that.

#4

So the only bit in the Title that you need help with is find in string?

#5

I need help with #6 (finding the word 'connected' in the string) and with #3, navigating to a different page after logging in. I don't know how to place my nodes for that. Would two http request nodes in a row work for this? One logging in and one navigating to a nested page on that website?

Here's a screenshot of what I've been trying:

#6

Yes, you can make two http request node calls in a row, but you may need to clear the msg.req and/or msg.res properties between calls (at least, you used to). Otherwise, the second node tries to reuse some of the first node's properties. I'm guessing that only Nick would have a definitive answer for why this is (or no longer is) necessary... but if the second call fails, you could try using a change node to delete those properties after the first call.