How to interact with webpage button?

12 次查看(过去 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