使用 PHP 简单 HTML DOM 解析器获取 Google 应用程序状态
我想使用 PHP Simple HTML DOM Parser 来获取 Google Apps 状态表,以便我可以创建自己的仪表板,其中仅包含 Google Mail 和 Google Talk 服务状态,以及更改演示文稿(html、css)。
作为测试,我想查找/输出表元素,但它没有显示任何结果。
$html = file_get_html('http://www.google.com/appsstatus');
$e = $html->find("table", 0);
echo $e->outertext;
不过,如果我找到/输出 div 元素,它将显示结果。
$html = file_get_html('http://www.google.com/appsstatus');
$e = $html->find("div", 0);
echo $e->outertext;
任何帮助将不胜感激。
I wanted to use PHP Simple HTML DOM Parser to grab the Google Apps Status table so I can create my own dashboard that will only include Google Mail and Google Talk service status, as well as change the presentation (html,css).
As a test, I wanted to find/output the table element but it's not displaying any results.
$html = file_get_html('http://www.google.com/appsstatus');
$e = $html->find("table", 0);
echo $e->outertext;
Although, if I find/output the div elements it will display results.
$html = file_get_html('http://www.google.com/appsstatus');
$e = $html->find("div", 0);
echo $e->outertext;
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这比那容易得多。所有这些数据都绑定在 JSON feed 中。
http://www.google.com/appsstatus/json/en
简单级别,你可以执行一个
file_get_contents()
,将前面写着dashboard.jsonp
的部分敲掉,然后执行json_decode()
> (doc),你将拥有一个包含所有内容的漂亮数组您想了解的有关 Google 服务状态的信息。使用print_r()
转储它以查看所有内容在哪里。使用 Fiddler 查找这些类型的内容非常容易。我强烈推荐它。
It's way easier than that. All of this data is tied up in a JSON feed.
http://www.google.com/appsstatus/json/en
On a simple level, you could do a
file_get_contents()
of that, knock that bit off the front that saysdashboard.jsonp
, and then to ajson_decode()
(doc), and you will have yourself a nice array with all the information you'd ever want to know about Google's service status. Dump it withprint_r()
to see where everything is.Finding these types of things is super easy with Fiddler. I highly recommend it.