I want to grab data from a webpage and display it in my Android app. The problem is, the elements I want from the HTML must be first created by an ajax call.
Because the data is loaded via Javascript my approach is to use a Webview to return the HTML. I use the method outlined by jluckyiv here : How do I get the web page contents from a WebView?
However, I realized this doesn't work because the ajax calls have not returned by when the javascript has finished running.
Are there any solutions? I don't have the access to modify the code on the webpage.
Do you use setJavaScriptEnabled(true) ?
Related
I want to get data from html page, but the page has onload functions which aren't executed when I use the get method of requests.Session().
with Session() as s:
s.get('https://o2.amdm.pro/amdm/S/S/S/insure/Portfolio#/entityHandle=01%7CPD%7C00000000000001384776%7C0001%7C0001', stream=True)
My question is, how to execute those functions as if I was in a browser to get the missing data in order to fill the main div ? Or at least, load the page in a browser and get the html from this page fully loaded ?
My question is, how to execute those functions as if I was in a browser to get the missing data in order to fill the main div ?
You need tool with JavaScript support for that, if you want one similar in usage to python-requests I suggest giving a try Requests-HTML.
load the page in a browser and get the html from this page fully loaded
For that you need web automation tool, here I suggest trying Selenium.
So I am currently trying to implement AJAX functionality to my webapp.
I currently have all the Tag Library, Tag Handlers, set up properly, so that if I call the Tags when the page is fully refreshing. All these custom tags work.
However, I have actually never implemented ajax in my life and is currently stuck on how to proceed to call these tags dynamically based on the changes in the webpage.
E.X:
Custom Tag library under -->/WEB-INF/tld
Tag Handlers --> classes/ClassHandlers/Tag1...TagXXX
With the above calling the following tag in the JSP file works perfectly:
<tagLib:tagName Attribute1="" Attribute2="">
However, how can I get this to be dynamically inserted by Ajax?
Please let me know if I can provide any more details.
Well, I would said that it is impossible. AJAX and JSP are two incompatible technologies. JSP tags can be used only on server side (during generating HTML) while AJAX is a client side technology (it runs in user browser). You can read more about client-server model here.
I have a webview that wants to retrieve certain String value via a javascript function. I use a JavascriptInterface to print that value. This javascript lives inside a tag in a hosted HTML.
Then, when I call view.loadUrl("javascript:JSInterface.print(myFunction());") it just doesn't print anything.
However, I noticed that if I take the HTML source code and put it into my project assets and load it from there then the instruction works ok and print the desired value.
Are there any security reasons that disables calling javascript functions when they are loaded from Internet?
Ok the problem is that if you use webview.loadDataWithBaseUrl() then the javascript functions and variables will be invalidated, thus you won't be able to access them with webview.loadUrl.
Using loadUrl to load the HTML works but it will remove the possibility to alter the HTML before it is loaded.
Is there any way for me to run Javascript in a Rails controller? I basically have a Javascript widget that I am loading in the browser right now (the script is hosted somewhere else).
I want to run it server-side, and then parse it's output (renders HTML) and return it via an API call. Is this even possible?
I think what you are talking about is a _partial_name_here.js.erb template. You can render it like any partial from the controller, and you can write your JS there. More details here.
Since jsff file is a fragment in the web page; how can we call a javascript function on 'onload' of that jsff file.
Here is my use case -
I have a taskflow with JSF fragments input.jsff & output.jsff.
Flow of my taskflow is starts with input.jsff, which takes some input from user & output.jsff, which shows the output by processing the input data.
Dropped this taskflow into a jspx file.
jspx file has some javascript methods.
I have to call one of the javascript method while loading output.jsff.
Is there any way to do this ?
If you want just call javascript method on page load use
<af:clientListener type="load" method="jsMethod"/>
hooked to the document tag.
If you need to do certain actions while loading some stuff, use taskflows with few views/steps instead. One step showes one thing, calls method or anything, then proceed to another view.
Its always recommended avoiding the use of java script in oracle adf . If you are trying to invoke a method in java , using java script , you should probably try to add a method as a default-activity in the task-flow and invoke the taskflow .
If you could probably tell what you are trying to do with the java script we would be able to help you better.