How to interact with webpage button?

조회 수: 7 (최근 30일)
b
b 2022년 10월 13일
답변: Rahul 2025년 6월 24일
A webpage has quiz questions with 4 answers. Unless the user presses 'Send' button (with or without selecting any option for any question), the answers are not revealed.
The answers are revealed, once the user presses the 'send' button. This then appears in page source.
The answer url cannot be read directly by urlread because it doesn't show the answers.
How to simulate the pressing of this 'send' button so that urlread can read the page source of the answer-page?

답변 (1개)

Rahul
Rahul 2025년 6월 24일
Hi @b,
I understand that you wish to implement the functionality of interacting with a button on a webpage using MATLAB. There are a few things to keep in mind.
  • If the webpage is implementing just a POST/GET request in the background after the button is pressed, the you might be able to use 'webwrite' to invoke simple POST requests to obtain the static html which would come after the button press.
  • However, if the webpage is based on React/Angular or uses Javascript for DOM Manipulation, then MATLAB alone would not be able to implement the functionality as it does not directly deal with JavaScript.
  • In that case, consider using selenium using python to interact with the webpage and simulate the button click and execute Javascript for DOM Manipulation. Then 'pyenv' function can be used in MATLAB to obtain the html from the python executable file, which can be used to demostrate data iun MATLAB.
The following MathWorks documentations can be referred:
Thanks.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by