Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Getting text response from browser
Getting text response from browser [message #648475] Thu, 13 January 2011 04:52 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
I'm trying to figure out a way to get the loaded results back from a browser after the load completes. I've been able to hack something that does this in SWT but for unsurprising reasons that technique doesn't translate to RAP world. Here's what I've looked at:

From ExternalBrowser: It appears that there is no way to do this at least form existing API. You can open and close a window but it looks like the contents are available. Perhaps there are deep security issues that prevent this from being supported in any case?

From Browser: Here, the html is available as local state, and theoretically can be obtained using BrowserAdapter. My thinking was to do a setURL and then wait for the load via ProgressListener. That sort of works, in that the listener is notified for changed and (typically, but not always...I've noticed that some pages never actually complete!) completed but there is never anything in Browser.this.html. It appears that Browser.setText is never called internally.

any ideas most appreciated,

Miles
Re: Getting text response from browser [message #648492 is a reply to message #648475] Thu, 13 January 2011 08:14 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Miles,
Browser#getText() method is not yet implemented in RAP - see bug:
314743: Add Browser.getText() method to API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=314743
Currently, it's not possible to get the content of the loaded page. In
RAP, this will never be possible for pages, loaded from a different than
the application domain due to browser security restrictions, but in
theory should be possible for pages loaded from the same domain.
Best,
Ivan

On 1/13/2011 6:52 AM, Miles Parker wrote:
> I'm trying to figure out a way to get the loaded results back from a
> browser after the load completes. I've been able to hack something
> that does this in SWT but for unsurprising reasons that technique
> doesn't translate to RAP world. Here's what I've looked at:
>
> From ExternalBrowser: It appears that there is no way to do this at
> least form existing API. You can open and close a window but it looks
> like the contents are available. Perhaps there are deep security
> issues that prevent this from being supported in any case?
>
> From Browser: Here, the html is available as local state, and
> theoretically can be obtained using BrowserAdapter. My thinking was to
> do a setURL and then wait for the load via ProgressListener. That sort
> of works, in that the listener is notified for changed and (typically,
> but not always...I've noticed that some pages never actually
> complete!) completed but there is never anything in Browser.this.html.
> It appears that Browser.setText is never called internally.
>
> any ideas most appreciated,
>
> Miles
Re: Getting text response from browser [message #648659 is a reply to message #648492] Thu, 13 January 2011 20:04 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Ivan Furnadjiev wrote on Thu, 13 January 2011 03:14
Hi Miles,
Browser#getText() method is not yet implemented in RAP - see bug:
314743: Add Browser.getText() method to API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=314743
Currently, it's not possible to get the content of the loaded page. In
RAP, this will never be possible for pages, loaded from a different than
the application domain due to browser security restrictions, but in
theory should be possible for pages loaded from the same domain.


Aha. I feel a kind of perverse satisfaction when I can't do something because of an actual bug rather than due to my own ignorance!

I thought that this would be the case for external pages. Perhaps I can accomplish the same thing by loading it rom a RAP internal frame...? Or is it possible to treat a URL post somehow as a browser request without actually displaying it in a browser?

thanks,

Miles
Re: Getting text response from browser [message #649572 is a reply to message #648659] Wed, 19 January 2011 18:23 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
I've commented on the bug, but I wanted to ping back with the question below since I'm still stymied on a solution. Is there any way at all that given a user context, we can open an arbitrary URL on the client side such that the results cam be forwarded to the server or is there something deep in the browser security model that would prevent any such thing from happening?

Put another way, is there anyway to get information from client side that is not directly inputted by client back in to the server side data model?

Right now I'm thinking now that the only way to do this would be through some kind of client side Javascript thing, with user intervention, i.e. the user a) clicks to submit a URL, b) gets the results of that URL query within a frame, and then c) manually submits that back to a servlet, but I'd love to find a (secure) way to automate it.

Miles Parker wrote on Thu, 13 January 2011 15:04
Ivan Furnadjiev wrote on Thu, 13 January 2011 03:14
Hi Miles,
Browser#getText() method is not yet implemented in RAP - see bug:
314743: Add Browser.getText() method to API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=314743
Currently, it's not possible to get the content of the loaded page. In
RAP, this will never be possible for pages, loaded from a different than
the application domain due to browser security restrictions, but in
theory should be possible for pages loaded from the same domain.


Aha. I feel a kind of perverse satisfaction when I can't do something because of an actual bug rather than due to my own ignorance!

I thought that this would be the case for external pages. Perhaps I can accomplish the same thing by loading it rom a RAP internal frame...? Or is it possible to treat a URL post somehow as a browser request without actually displaying it in a browser?

thanks,

Miles

Re: Getting text response from browser [message #649592 is a reply to message #649572] Wed, 19 January 2011 20:35 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

Miles,

According to my understanding of browser security policies, you would only be able to access the contents of an iframe if it was loaded from the same domain as your page (or visa versa, the iframe access the parent page). Given that restriction it seems like this would be of limited usefulness. If you already have the content on your server there is probably an easier/better way to get it into your RAP application than passing it through the client browser. OTHO if you are trying to access something from another domain you would probably need some cooperation from that site's administrator.

I'm not sure exactly what you are trying to accomplish, but automating websites and/or scraping information is probably possible with a user script (aka greasemonkey) or a browser extension.

Cole
Re: Getting text response from browser [message #649596 is a reply to message #649592] Wed, 19 January 2011 20:50 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Cole Markham wrote on Wed, 19 January 2011 15:35

...If you already have the content on your server there is probably an easier/better way to get it into your RAP application than passing it through the client browser. OTHO if you are trying to access something from another domain you would probably need some cooperation from that site's administrator. ..I'm not sure exactly what you are trying to accomplish, but automating websites and/or scraping information is probably possible with a user script (aka greasemonkey) or a browser extension.



Thanks Cole. I really appreciate your insights on this..as web client side is new territory for me. In this case, because of server side cleverness, it is basically impossible to get the information without acting as a regular user typing a URL. Every other attempt to get the results back in the obvious way, i.e. through HTTPConnection, etc.. has failed.

[you would only be able to access the contents of an iframe if it was loaded from the same domain as your page]

Would that be doable using a RAP managed widget of some kind? I'm not even sure that you could use an iframe container, so I need to do some more experimentation with that but natch I'm trying to avoid requiring browser side extensions at all costs.
Re: Getting text response from browser [message #650034 is a reply to message #649592] Fri, 21 January 2011 14:05 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.

This is exactly the situation. Getting text from the browser-widget is
only possible if the content came from your server anyway, i.e. you
should be able to access it directly from wherever it is located.

If you want to get the content of any external website, the
BrowserWidget would be the wrong tool to do so, at least in RAP. You
would have to somehow create your own http-request to send directly from
the server to the site in question, completely without the help of the
client.

Greetings,
Tim


Am 19.01.2011 21:35, schrieb Cole Markham:
> Miles,
>
> According to my understanding of browser security policies, you would
> only be able to access the contents of an iframe if it was loaded from
> the same domain as your page (or visa versa, the iframe access the
> parent page). Given that restriction it seems like this would be of
> limited usefulness. If you already have the content on your server there
> is probably an easier/better way to get it into your RAP application
> than passing it through the client browser. OTHO if you are trying to
> access something from another domain you would probably need some
> cooperation from that site's administrator.
> I'm not sure exactly what you are trying to accomplish, but automating
> websites and/or scraping information is probably possible with a user
> script (aka greasemonkey) or a browser extension.
>
> Cole
Re: Getting text response from browser [message #650103 is a reply to message #650034] Fri, 21 January 2011 18:16 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Tim Buschtoens wrote on Fri, 21 January 2011 09:05

If you want to get the content of any external website, the
BrowserWidget would be the wrong tool to do so, at least in RAP. You would have to somehow create your own http-request to send directly from the server to the site in question, completely without the help of the client.


thanks Tim, it's a bummer but it's good to know for certain that it is just impossible. It looks like I'll have to go down the GreaseMonkey/Extension route, though I'm leery of that as I could end up opening up security vulnerabilities inadvertently.
Previous Topic:Multitab browsing
Next Topic:RAP 1.4 M4 + browser widget & infinity loading status in FF
Goto Forum:
  


Current Time: Tue Apr 23 06:45:56 GMT 2024

Powered by FUDForum. Page generated in 0.03809 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top