How to click a button on a website usin an ESP32

Hi,
So I wish to use an ESP32 to click a button on a website to interact with it

The button looks like this:
<input type="button" value="ReLoad" onclick="refreshHref()">

How do i do it?

This is a good start: https://randomnerdtutorials.com/esp32-web-server-arduino-ide/

Hi,
I wish to interact with an existing website, not create a new one

How much have You done so far? Making connection to a website?

It appears that your ESP32, acting like a web browser, should execute the javascript function refreshHref(). If you can't find a javascript interpreter for the ESP32 you can try looking into the javascript function to see if the ESP32 can pretend to execute it.

If you turn off javascript support, does the website present a simplified HTML page?

Yep, have managed to scrape the website, just unsure how to interact with it.

Some parts of the code:


client.println("GET /sensor/sensor.php?data=0");
client.println(" HTTP/1.1");

client.connect(host, 80);

client.print(String("GET /SETUP/05_INFOMATION/02_AUDIOINPUTSIGNAL/d_audioinputsignal.asp") + " HTTP/1.1\r\n" +
             "Host: " + host + "\r\n" +
             "Connection: close\r\n" +
             "\r\n"
            );

    unsigned long timeout = millis();
    while (client.available() == 0) {
        if (millis() - timeout > 5000) {
            Serial.println(">>> Client Timeout !");
            client.stop();
            return;
        }
    }

Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
Heltec.display->setFont(ArialMT_Plain_10);

int oldval = 0;
int newval = 0;

while (client.available()) {


  
String line = client.readStringUntil('\r');
//Serial.println(line);
if (line.indexOf( "<TR><TD><b>&nbsp;&nbsp;Surround Mode</b></TD><TD>" ) > 0 ) {
  Serial.println();
  String t = ("  - " + midString(line, "<TR><TD><b>&nbsp;&nbsp;Surround Mode</b></TD><TD>" , "</TD></TR>" ));
  Serial.println(midString(line, "<TR><TD><b>&nbsp;&nbsp;Surround Mode</b></TD><TD>" , "</TD></TR>" ));
  Heltec.display -> drawString(0, 0, "  Surround mode:");
  Heltec.display -> drawString(0, 10, t);
  newval = newval+1;

}
}

If i turn off javascript, i only a simplefied HTML page lacking the info i need.

Have you found the definition of the refreshHref() function? If so, what does it contain? If not, keep looking.

Without the ability to change the source of webpage, I think it is very very difficult to do what you want.

Your code is not clear: why you print the first two lines before connecting to remote host?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.