无法使用PHP从CollegeBoard获取内容

时间:2015-07-21 10:18:57

标签: javascript php regex web-scraping dynamic-content

https://bigfuture.collegeboard.org/college-university-search/dickinson-college

我试图使用PHP的preg_match函数获取此页面的内容:

$filename = 'https://bigfuture.collegeboard.org/college-university-search/dickinson-college';
$content = file_get_contents($filename);

$subject = $content;
$pattern = '#(?<=<span class="locality" itemprop="addressLocality">)(\w*)(?=<\/span>)#';
preg_match($pattern,$subject,$city);

print_r($city);

我想要获取的信息在div中,类为“clearfix margin60 marginBottomOnly”。

在Chrome中使用Firebug或“Ins​​pect Element”时,此div中的内容可见。 但是,当我查看页面源时,div为空。

有人可以告诉我原因以及如何从页面获取我想要的内容(例如,学校的位置)吗?

1 个答案:

答案 0 :(得分:2)

你没有看到它,因为内容是由JavaScript函数生成的,如果你将检查“脚本”标签并查找div名称[gwtDiv],你将会生成什么脚本,

&# XA;
相关问题