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

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Chi
Chi el 17 de Jun. de 2019
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 :

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by