为什么不
$txt = file_get_contents('https://www.cloudflare.com/system-status.html');
获取https://www.cloudflare.com/system-status.html
的正确源代码 file_get_contents <div class="article">
输出:
<div class="article">
<div id="cfstatus-table-wrapper" style="display: none;">
<table id="cfstatus-table">
<thead>
<tr>
<th class="cfstatus-table-location"></th>
<th class="cfstatus-table-current">Current status</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-0">Sep 8</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-1">Sep 7</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-2">Sep 6</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-3">Sep 5</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-4">Sep 4</th>
<th class="cfstatus-table-history cfstatus-table-lastColumn" id="cfstatus-table-history-5">Sep 3</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div id="cfstatus-table-corners"><div id="cfstatus-table-corner-tl"></div><div id="cfstatus-table-corner-tr"></div><div id="cfstatus-table-corner-br"></div><div id="cfstatus-table-corner-bl"></div></div>
</div>
</div>
实际<div class="article">
输出:
<div class="article">
<div id="cfstatus-table-wrapper" style="">
<table id="cfstatus-table">
<thead>
<tr>
<th class="cfstatus-table-location"></th>
<!-- -->
<th class="cfstatus-table-current">Current status</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-0">Mar 17</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-1">Mar 16</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-2">Mar 15</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-3">Mar 14</th>
<th class="cfstatus-table-history" id="cfstatus-table-history-4">Mar 13</th>
<th class="cfstatus-table-history cfstatus-table-lastColumn" id="cfstatus-table-history-5">Mar 12</th>
<!-- -->
</tr>
</thead>
<tbody><tr id="cfstatus-table-cf"><th class="cfstatus-table-location" id="cfstatus-table-location-cf">CloudFlare System</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr>
<tr><th class="cfstatus-table-location">Amsterdam, NL</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="performance-degradation cfstatus-table-history cfstatus-table-lastColumn" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Performance degradation</span></td></tr><tr><th class="cfstatus-table-location">Ashburn, VA</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Chicago, IL</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Dallas, TX</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="status-report cfstatus-table-history cfstatus-table-lastColumn" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Status report</span></td></tr><tr><th class="cfstatus-table-location">Frankfurt, DE</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Hong Kong, HK</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">London, GB</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="status-report cfstatus-table-history cfstatus-table-lastColumn" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Status report</span></td></tr><tr><th class="cfstatus-table-location">Los Angeles, CA</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="performance-degradation cfstatus-table-history" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Performance degradation</span></td><td class="performance-degradation cfstatus-table-history" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Performance degradation</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Miami, FL</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Newark, NJ</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Paris, FR</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">San Jose, CA</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="performance-degradation cfstatus-table-history" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Performance degradation</span></td><td class="performance-degradation cfstatus-table-history" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Performance degradation</span></td><td class="status-report cfstatus-table-history" style="cursor: pointer; opacity: 1; "><div class="icon"></div><span class="label">Status report</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Singapore, SG</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr><tr><th class="cfstatus-table-location">Tokyo, JP</th><td class="online cfstatus-table-current"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history"><div class="icon"></div><span class="label">Online</span></td><td class="online cfstatus-table-history cfstatus-table-lastColumn"><div class="icon"></div><span class="label">Online</span></td></tr></tbody>
</table>
<div id="cfstatus-table-corners"><div id="cfstatus-table-corner-tl"></div><div id="cfstatus-table-corner-tr"></div><div id="cfstatus-table-corner-br"></div><div id="cfstatus-table-corner-bl"></div></div>
</div>
</div>
我不知道为什么会这样;任何建议将不胜感激。
答案 0 :(得分:2)
该表不是静态HTML,而是在页面加载时由JavaScript构建。
您可以使用their JSON API at https://www.cloudflare.com/ajax/sys-status.html
代替您的网站执行相同操作。但是先请他们批准。