如何使用 cURL 获取 JavaScript 加载的网页内容? [英] How to get webcontent that is loaded by JavaScript using cURL?

查看:39
本文介绍了如何使用 cURL 获取 JavaScript 加载的网页内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从网站获取分数表.问题是该站点使用的 javascript 显然是在 document.ready 上加载的.

I am trying to grab the score table from a website. The problem is that the site is using javascript that apparently loads on document.ready.

出于这个原因,我似乎没有成功获得表格,而我得到的只是该页面顶部的按钮.

For that reason I don't seem to succeed getting the table and all I get is the buttons at the top of that page.

关于如何解决这个问题有什么建议或想法吗?

Any suggestions or ideas on how to solve this?

推荐答案

cURL 只会让你得到页面的标记.它不会加载任何额外的资源或处理页面.为此,您可能想查看类似 PhantomJS 的内容.PhantomJS 是一个无头 WebKit 浏览器.它有自己的 API,可让您编写脚本"行为.所以你可以告诉 PhantomJS 加载页面并转储你需要的数据.

cURL will only get you the markup of the page. It won't load any additional resources or process the page. You probably want to look at something like PhantomJS for this. PhantomJS is a headless WebKit browser. It has its own API that lets you "script" behavior. So you can tell PhantomJS to load the page and dump out the data you need.

这篇关于如何使用 cURL 获取 JavaScript 加载的网页内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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