簡體   English   中英

無法使用PHP從CollegeBoard獲取內容

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM