独立的Javascript布局引擎? [英] Standalone Javascript layout engine?

查看:126
本文介绍了独立的Javascript布局引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我从网站(我无法控制)检索到HTML内容,并且该内容包含很多Javascript代码,这些代码是布局引擎(例如WebView)实际呈现内容的重要部分。

b
$ b

有没有一种方法可以自己渲染它?

例如,在极端情况下,假设我正在访问一个网站几乎没有任何内容,但通过一系列Javascript函数显示非常丰富的TEXT内容(显然导致HTML)。



访问/读取HTML结果的方式如何?



我试图在Android上这样做。



更新,试图为@abesto提供更多上下文。如果您访问facebook.com并将呈现的内容复制/粘贴到文本文件中,您将收到:

  Facebook徽标
电子邮件密码

保持登录状态忘记密码?
Facebook可以帮助您与生活中的人们建立联系和分享。
注册
它是免费的,而且一直都是。
名字:
姓氏:
您的电子邮箱:
重新输入电子邮件:
新密码:
我是:
生日:

为什么我需要提供这个?
安全检查
此字段是必填项。
在下面输入两个单词,用空格分隔。
无法读取下面的单词吗?尝试不同的单词或音频验证码。
请输入您听到的文字或数字。
尝试不同的单词或回到文本。
载入中...
包装盒中的文字:
这是什么?

返回
注册...
发生错误。请再试一次。

点击注册即表示您已阅读并同意使用条款和隐私政策。
为名人,乐队或企业创建一个页面。

*Română
*英文(美国)
*西班牙文
*Português(巴西)
*Français(法国)
* Deutsch
* Italiano
*العربية
*हिन्दी
*中文(简体)


Facebook©2011·English(US)
手机·找朋友·徽章·人们·页面·关于·广告·开发人员·招聘·隐私·条款·帮助

但是,如果你看看实际的源代码(你在HttpResponse中得到了什么),你会看到更多的怪异文本......主要是javascript。



I我只对这个Javascript的结果感兴趣。任何想法如何做到这一点?

解决方案

我认为答案是肯定的,但不要那样做。



如果我必须实施将'Facebook'翻译成手机的解决方案,我可以使用浏览器自动化解决方案在亚马逊EC2上安装服务器并运行浏览器,例如 Watir 来模拟点击并从页面上删除数据。我认为这是太多的希望,因为你可以在手机本身背后高效运行。



然而,更好的解决方案可能是使用Firebug / Fiddler等对发送的ajax调用进行反向工程并找到获取底层数据的方法?或者,也许你只需要反向工程JS:(。


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 do 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 :(.

这篇关于独立的Javascript布局引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆