Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a JavaScript command from MATLAB to fetch a PDF file

I'm currently writing some MATLAB code to interact with my company's internal reports database. So far I can access the HTML abstract page using code which looks like this:

import com.mathworks.mde.desk.*;
wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser;
wb.setCurrentLocation(ReportURL(8:end));
pause(1);

s={};
while isempty(s)
    s=char(wb.getHtmlText);
    pause(.1);
end
desk=MLDesktop.getInstance;
desk.removeClient(wb);

I can extract out various bits of information from the HTML text which ends up in the variable s, however the PDF of the report is accessed via what I believe is a JavaScript command (onClick="gotoFulltext('','[Report Number]')").

Any ideas as to how I execute this JavaScript command and get the contents of the PDF file into a MATLAB variable?

(MATLAB sits on top of Java, so I believe a Java solution would work...)

like image 414
Ian Hopkinson Avatar asked Aug 21 '09 10:08

Ian Hopkinson


1 Answers

I think you should take a look at the JavaScript that is being called and see what the final request to the webserver looks like.

You can do this quite easily in Firefox using the FireBug plugin.

https://addons.mozilla.org/en-US/firefox/addon/1843

Once you have found the real server request then you can just request this URL or post to this URL instead of trying to run the JavaScript.

like image 176
pjp Avatar answered Nov 15 '22 01:11

pjp