[英]Unable to fetch content from CollegeBoard using PHP
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或“检查元素”时,此div中的内容可见。 但是,当我查看页面源代码时,div为空。
谁能告诉我原因以及如何从页面中获取我想要的内容(例如学校的位置)?
您看不到它,因为内容是由JavaScript函数生成的,如果您将检查“脚本”选项卡并查找div名称[gwtDiv],那么您将生成什么脚本,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.