PHP简单HTML DOM虽然没有找到整个文档的元素

时间:2017-09-23 00:19:07

标签: php domdocument simple-html-dom

我正在尝试从Pro-Football Reference

中提取数据

该表位于标签OFFENSE TOTALS

之后的底部

这是我的代码:

$url = ("https://www.pro-football-reference.com/play-index/drive_finder.cgi?request=1&year_min=".$season."&year_max=".$season."&game_type=R&game_num_min=0&game_num_max=99&week_num_min=".$week."&week_num_max=".$week."&start_event%5B%5D=Downs&start_event%5B%5D=Interception&start_event%5B%5D=Punt&start_event%5B%5D=Blocked+FG&start_event%5B%5D=Missed+FG&start_event%5B%5D=Fumble&start_event%5B%5D=Muffed+Punt&start_event%5B%5D=Blocked+Punt&start_event%5B%5D=Kickoff&start_event%5B%5D=Onside+Kick&start_event%5B%5D=Own+Kickoff&start_event%5B%5D=Muffed+Kickoff&end_event%5B%5D=Touchdown&end_event%5B%5D=Field+Goal&end_event%5B%5D=Missed+FG&end_event%5B%5D=Fumble&end_event%5B%5D=Interception&end_event%5B%5D=Downs&end_event%5B%5D=Punt&end_event%5B%5D=Blocked+Punt&end_event%5B%5D=Blocked+FG&end_event%5B%5D=Safety&end_event%5B%5D=End+of+Half&end_event%5B%5D=End+of+Game&exclude_kneels=1&drive_st_gtlt=lt&drive_st_own_opp=Own&drive_end_gtlt=lt&drive_end_own_opp=Opp&drive_end_yds=20&drive_num_gtlt=gt&start_quarter%5B%5D=1&start_quarter%5B%5D=2&start_quarter%5B%5D=3&start_quarter%5B%5D=4&start_quarter%5B%5D=5&end_quarter%5B%5D=1&end_quarter%5B%5D=2&end_quarter%5B%5D=3&end_quarter%5B%5D=4&end_quarter%5B%5D=5&tr_gtlt=lt&minutes=15&seconds=0&order_by=game_date");

$html = file_get_html($url);
foreach($html->find('div#div_offense_totals') as $e)
    echo $e->innertext . '<br>';

什么都不会回来

如果你这样做

foreach($html->find('div.table_outer_container') as $e)
     echo $e->innertext . '<br>';

您将获得结果,但它们是页面顶部的结果,即使底部相同的div和类也是如此。

完全不知道这个。

真实网址

https://www.pro-football-reference.com/play-index/drive_finder.cgi?request=1&year_min=2014&year_max=2014&game_type=R&game_num_min=0&game_num_max=99&week_num_min=1&week_num_max=1&start_event%5B%5D=Downs&start_event%5B%5D=Interception&start_event%5B%5D=Punt&start_event%5B%5D=Blocked+FG&start_event%5B%5D=Missed+FG&start_event%5B%5D=Fumble&start_event%5B%5D=Muffed+Punt&start_event%5B%5D=Blocked+Punt&start_event%5B%5D=Kickoff&start_event%5B%5D=Onside+Kick&start_event%5B%5D=Own+Kickoff&start_event%5B%5D=Muffed+Kickoff&end_event%5B%5D=Touchdown&end_event%5B%5D=Field+Goal&end_event%5B%5D=Missed+FG&end_event%5B%5D=Fumble&end_event%5B%5D=Interception&end_event%5B%5D=Downs&end_event%5B%5D=Punt&end_event%5B%5D=Blocked+Punt&end_event%5B%5D=Blocked+FG&end_event%5B%5D=Safety&end_event%5B%5D=End+of+Half&end_event%5B%5D=End+of+Game&exclude_kneels=1&drive_st_gtlt=lt&drive_st_own_opp=Own&drive_end_gtlt=lt&drive_end_own_opp=Opp&drive_end_yds=20&drive_num_gtlt=gt&start_quarter%5B%5D=1&start_quarter%5B%5D=2&start_quarter%5B%5D=3&start_quarter%5B%5D=4&start_quarter%5B%5D=5&end_quarter%5B%5D=1&end_quarter%5B%5D=2&end_quarter%5B%5D=3&end_quarter%5B%5D=4&end_quarter%5B%5D=5&tr_gtlt=lt&minutes=15&seconds=0&order_by=game_date

0 个答案:

没有答案