简体   繁体   English

无法使用PHP从CollegeBoard获取内容

[英]Unable to fetch content from CollegeBoard using PHP

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

I was trying to fetch the content of this page using PHP's preg_match function: 我试图使用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);

The info that I want to fetch is within the div with class "clearfix margin60 marginBottomOnly". 我要获取的信息在div中,类为“ clearfix margin60 marginBottomOnly”。

When using Firebug or 'Inspect Element' in Chrome, the content within this div is visible. 在Chrome中使用Firebug或“检查元素”时,此div中的内容可见。 However when I viewed the page source, the div is empty. 但是,当我查看页面源代码时,div为空。

Could anybody tell me the reason and how to get the content that I want from the page (for eg, the location of the school)? 谁能告诉我原因以及如何从页面中获取我想要的内容(例如学校的位置)?

您看不到它,因为内容是由JavaScript函数生成的,如果您将检查“脚本”选项卡并查找div名称[gwtDiv],那么您将生成什么脚本,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM