下载 javascript 加载的页面
我正在查看的示例是 morningstar .com。 大部分内容都是通过这个javascript函数加载的。当我使用 wget 时,我没有获得浏览器中实际显示的数据(因为 wget 不解释 javascript 代码)。
有没有某种方法可以评估 javascript 并下载整个页面(使用命令行或代码)?
SRT_stocFund.LoadAComponent("sfcontent", "C", "is", "en-us","USA", "", "USA", null,{showSubTab: false});
The example I'm looking at is morningstar.com.
Most of the contents are loaded through this javascript function. When I use wget, I don't get the data that actually show up in the browser (because wget doesn't interprets javascript code).
Is there some way to evaluate the javascript and download the full page (with cmdline or code)?
SRT_stocFund.LoadAComponent("sfcontent", "C", "is", "en-us","USA", "", "USA", null,{showSubTab: false});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于该特定页面,也许您可以获取“导出”按钮的 URL?显然,只有当您尝试使用站点显示的实际数据时,这才有效(因为这就是摘录中的全部数据)。
以下是直接指向 .csv 文件的链接:http://financials.morningstar.com/ajax/exportKR2CSV.html?t=GOOG&culture=en_us®ion=USA&order=asc&r=765325
For that specific page, maybe you could just wget the URL of the "Export" button? Obviously this will only work if you are trying to use the actual data that the site is displaying (since that is all that is in the extract).
Here is a link directly to the .csv file: http://financials.morningstar.com/ajax/exportKR2CSV.html?t=GOOG&culture=en_us®ion=USA&order=asc&r=765325
安装适用于 Firefox 的 Firebug,然后查看“网络”选项卡中的情况。这将显示 Firefox 对页面发出的所有网络请求。您可以从中复制任何 Ajax 请求的 URL(在 XHR 选项卡中),并查看响应。将 Ajax URL 提供给 wget(除非它是 POST,在这种情况下有点棘手)。
Install Firebug for Firefox, and check out what's going in the 'Net' tab. That'll show you all the network requests Firefox puts out for a page. From that you can copy the URL of any Ajax requests (in the XHR tab), and see the response. Feed the Ajax URL to wget (unless its a POST, in which case its a bit trickier).