开发者

Standalone Javascript layout engine?

Assuming I retrieved HTML content from a website (over which I have no control), and that content contains lots of Javascript code that's a significant part of what's actually rendered by a layout engine (e.g. WebView).

Is there a way I can render it myself?

For example, in the extreme case, suppose I am visiting a website that has almost nothing in its but displays very rich TEXT content, via a host of Javascript functions (which obviously results in HTML).

How do access/read that HTML result?

I am looking to do this on Android only.

Update, trying to provide more context to @abesto. If you go to facebook.com and copy/paste rendered content into a text file, you'll receive:

Facebook logo
Email   Password

Keep me logged in   Forgot your password?
Facebook helps you connect and share with the people in your life.
Sign Up
It's free and always will be.
First Name: 
Last Name:  
Your Email: 
Re-enter Email: 
New Password:   
I am:   
Birthday:   

Why d开发者_开发百科o I need to provide this?
Security Check
This field is required.
Enter both words below, separated by a space.
Can't read the words below?Try different words or an audio captcha.
Please enter the words or numbers you hear.
Try different words or back to text.
Loading...
Text in the box:
What's this?

Back
Registering…
An error occurred. Please try again.

By clicking Sign Up, you are indicating that you have read and agree to the Terms of Use and Privacy Policy.
Create a Page for a celebrity, band or business.

    * Română
    * English (US)
    * Español
    * Português (Brasil)
    * Français (France)
    * Deutsch
    * Italiano
    * العربية
    * हिन्दी
    * 中文(简体)
    * »

Facebook © 2011 · English (US)
Mobile · Find Friends · Badges · People · Pages · About · Advertising · Developers · Careers · Privacy · Terms · Help

But if you look at the actual source (what you get in HttpResponse) you'll see much more monstrous text... mostly javascript.

I am only interested in the result of that Javascript. Any ideas how to accomplish this?


I think the answer is yes, but don't do that.

If I had to implement a solution for translating 'Facebook' to a mobile phone, I could set up a server, maybe on Amazon EC2 and run the browser there, using a browser automation solution, such as Watir to simulate the clicks and scrape the data off the page. I think it's too much to hope for that you could run that efficiently behind the scenes on the phone itself.

However, the better solution might be to use Firebug/Fiddler etc to reverse engineer the ajax calls being sent and find a way to get the underlying data? Or maybe you just need to reverse-engineer the JS :(.


It sounds like you want something like this :

http://jsconsole.com/

You basically load the url and mess with it. You just need to hook something into it to do it programmatically.

Take a look at their remote debugging explanation.

Since it's hooked upto to your android over a stream you can use any old PC technology you want to sniff the HTML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜