Search code examples
javascriptheadless

Call an external JavaScript function without a browser


I'm working on a raspberry pi project that connects to a Wi-Fi network that requires a user to click a "Log in" button by redirecting the webpage to an internal server, which presumably stores the MAC address in a table, and permits traffic to pass through.

Given that the pi will run headless, is there anyway to write a script that calls the button's java script function, preferably with something like cURL?


Solution

  • Use fiddler to sniff at the traffic. Figure out what is being submitted to the URL (form post, http/https, etc.) and create a cURL request (or Python or NodeJS ...) that submits the same information.

    If they are using CSRF tokens, you will have to request the web page first via cURL, grep the output, and submit using that same token. See one example here

    Sorry can't help much further without additional details.