HTML 解析 - 从 div 内的表格获取数据?
我对 HTML 解析/抓取的整个想法还比较陌生。我希望我能来这里获得我需要的帮助!
基本上我想要做的(我认为)是指定我希望从中获取数据的页面的 url。在这种情况下 - http://www.epgpweb.com/guild/us/Caelestraz/ Crimson/
从那里,我想获取 div id=snapshot_table 中的表 class=listing。
然后,我希望将该表嵌入到我自己的页面上,并在原始内容更新时更新它。
我读过 Google 和 Stackoverflow 上的一些其他帖子,还看过 Nettuts+ 上的教程,但似乎有点太多了,无法立即理解。
希望这里有人可以帮助我并使其尽可能简单:)
干杯,
Mat
--编辑--
截至上午 11:22 (GMT+10) 的当前代码
<?php
# don't forget the library
include('simple_html_dom.php');
?>
<html>
</head>
<body>
<?php
$html = file_get_html('http://www.epgpweb.com/guild/us/Caelestrasz/Crimson/');
$table = $html->find('#snapshot_table table.listing');
print_r($table);
?>
</body>
</html>
I am relatively new to the whole idea for HTML parsing/scraping. I was hoping that I could come here to get the help that I need!
Basically what I am looking to do (i think), is specify the url of the page I wish to grab the data from. In this case - http://www.epgpweb.com/guild/us/Caelestrasz/Crimson/
From there, I want to grab the table class=listing in the div id=snapshot_table.
I then wish to embed that table onto my own page and have it update when the original content is updated.
I have read a few of the other posts on Google and Stackoverflow, I also had a look at a tutorial on Nettuts+ but it just seemed to be a bit too much to take in at once.
Hopefully someone here can help me out and make this as simple as possible :)
Cheers,
Mat
--Edit--
Current code as of 11:22am (GMT+10)
<?php
# don't forget the library
include('simple_html_dom.php');
?>
<html>
</head>
<body>
<?php
$html = file_get_html('http://www.epgpweb.com/guild/us/Caelestrasz/Crimson/');
$table = $html->find('#snapshot_table table.listing');
print_r($table);
?>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我已经开始工作了,而且我学到了很多东西! :)
I think I got it to work, and I learned a lot! :)
看一下 PHP simple_html_dom 类。
接下来就可以解决这个问题了。
Take a look at the PHP simple_html_dom class.
Next this will do the trick.