Parse web data using JS and Google DevTools API into MATLAB App

조회 수: 4 (최근 30일)
Dmitry Kostyuk
Dmitry Kostyuk 2019년 5월 29일
댓글: Dmitry Kostyuk 2020년 7월 10일
Hello!
I'm working on the project of parsing web data from web-page using standard JS commands that implement from Google Chrome Console. However I want to get the web data into MATLAB and create a standalone App that works using these web data.
My answer is -- How can I get the access to the Google DevTools to implement the JS commands to get web data to the MATLAB App?
Any help or advice would be appreciate.

채택된 답변

Chi
Chi 2019년 6월 17일
As this answer, there is no direct way to acquire what you want. But there is an indirect way, by simulating keyboard press, mouse movement and mouse clicking. Here's an example (platform: Windows) for copying elements in the Chrome DevTools into Matlab Workplace and perhaps you can modify it accordingly.
system('start chrome "https://www.google.com/"');
import java.awt.*;
import java.awt.event.*;
% press F12 to activate Chrome DevTools
rob=Robot; % Create a Robot-object to do the key-pressing
rob.keyPress(KeyEvent.VK_F12)
rob.keyRelease(KeyEvent.VK_F12)
pause(2);
% move mouse cursor to where you want
mouse = Robot;
mouse.mouseMove(80,550); % pixel position on your screen. modify accordingly.
pause(1);
% right click to show menu
mouse.mousePress(InputEvent.BUTTON3_MASK);
pause(0.5);
mouse.mouseRelease(InputEvent.BUTTON3_MASK);
% move a little bit to activate second-level menu
for i=1:16
mouse.mouseMove(174+i,300); % modify accordingly
pause(0.0001);
end
pause(2);
% move the cursor to the second-level menu
for i=1:6
mouse.mouseMove(359+i,335); % modify accordingly
pause(0.0001);
end
pause(2);
% left click to do copy
mouse.mousePress(InputEvent.BUTTON2_MASK); %left click press
pause(0.5);
mouse.mouseRelease(InputEvent.BUTTON2_MASK); %left click release
% load the copied text into Matlab workspace
str=clipboard('paste');
To my experience, It might fail sometimes. So, not efficient, but hope it is helpful.
Acknowledgements :

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by