免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2117 | 回复: 3
打印 上一主题 下一主题

关于HTML::TableExtract的使用问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-02-21 15:14 |只看该作者 |倒序浏览
请教各位:以下一段是为获取网页中表格内容,但我运行程序或却毫无反应,请各位大侠看看有什么问题,谢谢啦
#!/usr/bin/perl -w
use strict;
use HTML::TableExtract;
# By headers
my $html=get("http://rammb.cira.colostate.edu/products/tc_realtime/archive_strmfcst.asp?storm_identifier=WP022013");
my $te = HTML::TableExtract->new();
print "start.\n";
$te->parse_file($html);
foreach my $ts ($te->tables) {
   print "start table.\n";
   print "Table (", join(',', $ts->coords), "):\n";
   foreach my $row ($ts->rows) {
      print "start row.\n";
      print join(',', @$row), "\n";
   }
}

论坛徽章:
0
2 [报告]
发表于 2013-02-21 18:25 |只看该作者
本帖最后由 兰花仙子 于 2013-02-21 18:25 编辑

1. 打开debug模式
2. 或者用Data::Dumper把对象dumper出来观察

论坛徽章:
0
3 [报告]
发表于 2013-02-25 13:14 |只看该作者
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use LWP::Simple;
  4. use HTML::TableExtract;
  5. my $html=get("http://rammb.cira.colostate.edu/products/tc_realtime/archive_strmfcst.asp?storm_identifier=WP022013");
  6. my $te = HTML::TableExtract->new();
  7. print "start.\n";

  8. $te->parse($html);
  9. my $table = $te->first_table_found;

  10. foreach my $ts ($te->tables) {

  11.    print "start table.\n";
  12.    print "Table (", join(',', $ts->coords), "):\n";
  13.    foreach my $row ($ts->rows) {
  14.       print "start row.\n";
  15.       print join(',', @$row), "\n";
  16.    }
  17. }
复制代码
回复 1# shixinqianli


   

论坛徽章:
0
4 [报告]
发表于 2013-02-25 13:14 |只看该作者
回复 2# 兰花仙子 他用的是parse_file


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP