Hi...im trying to do some scraping and get data on what all devices are connected in my local network and check for internet status.
Firstly i need to login into my router page (I know username and password but can't get it login using POST request method in node red ) ..i tried few but sadly none of those works ...can someone help me to get this authentication done?
My local router webpage is 192.168.0.1
Looks like this
A lot of routers have the login user id (usually "admin") and the password printed on a label on the bottom or back.
Some routers force you to change the password when you first login. If you did that but can't remember it, you probably have to reset the router using a straightened out paperclip.
@jbudd I want to do web scraping.. And I know the username and password
For example
Username: admin
Password: admin
I want to do POST request to login into page(192.168.0.1) from node red and get the cookie value and use the cookie to do some web scrapping from router page
You could try to reverse engineer the request it makes;
On a desktop browser:
Go to the login page.
Right click > inspect element.
Go to the network tab
Now login.
You will see all kinds of things appearing. The page it redirected to should be there as well.
Click once on that on that particular link and you should see some details about the headers that were send in the POST request.
Yes I get this.. But my router webpage timeouts every 30 mins so I need new cookies every 30 mins.. I need help on how to do POST request with username and password
What part "do you get" ? The post request (apparently) produces cookies, so you can store the cookies and everytime you interact with the page you use the cookie as auth method. There is a ResponseCookies key in the request node response.
I have never done this, but I think you need to figure out what http requests are made when logging on to the site. You can do that with your browser developer tools.
You can then mimic those http (post) requests in node-red.
... but I am fearing a bit that those requests are encrypted/hashed somehow so that just replaying them might not work.
what model is your router, and what exactly is it your trying to scrape or obtain from the HTML?
I ask, as does the router support SSH or telnet at all?
EDIT:
I Read the full description SSH/Telnet might be a little overkill.
I think the username/password is not visible in the request header output you have shared but it is encoded in the payload (or body) of the POST request.
So if I want to create a node-red application that automatically logs in into my modem then it should also implement the same secure remote password protocol. It is not impossible but far from easy.
@janvda that is a better approach to secure ssl-less pages.
Looking at op's output, they appear to use a similar approach with the jsencrypt library, the only way around will be by using something nbrowser or puppeteer (that actually launches a headless browser in the background).