我有我自己的外部網站,我想從網站獲取一些數據。我用CURL來獲取網站的內容,但我想要一些部分是:從網站獲取數據
編輯:非常坦率地說,我想獲取Facebook頁面的時間戳,如果您在頁面上使用Inspect元素,您將看到這樣的代碼:
<span class="fsm fwn fcg"><a class="_5pcq">
<abbr title="Tuesday, June 30, 2015 at 5:00pm" data-utime="1435663826" data-shorten="1" class="_5ptz timestamp livetimestamp">5 hrs</abbr></a>
<span class="fsm fwn fcg"><a class="_5pcq">
<abbr title="Tuesday, June 30, 2015 at 5:01pm" data-utime="1435663827" data-shorten="1" class="_5ptz timestamp livetimestamp">5 hrs</abbr></a>
<span class="fsm fwn fcg"><a class="_5pcq">
<abbr title="Tuesday, June 30, 2015 at 5:02pm" data-utime="1435663828" data-shorten="1" class="_5ptz timestamp livetimestamp">5 hrs</abbr></a>
<span class="fsm fwn fcg"><a class="_5pcq">
<abbr title="Tuesday, June 30, 2015 at 5:03pm" data-utime="1435663829" data-shorten="1" class="_5ptz timestamp livetimestamp">5 hrs</abbr></a>
<span class="fsm fwn fcg"><a class="_5pcq">
<abbr title="Tuesday, June 30, 2015 at 5:04pm" data-utime="1435663830" data-shorten="1" class="_5ptz timestamp livetimestamp">5 hrs</abbr></a>
</span>
我只是想顯示「數據UTIME」是1435663826.這裏的價值是我的代碼,將獲取的內容。在此之後我應該使用什麼?
$cookie = tmpfile();
$userAgent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31' ;
$ch = curl_init("https://www.mywebsite.com");
$options = array(
CURLOPT_CONNECTTIMEOUT => 20 ,
CURLOPT_USERAGENT => $userAgent,
CURLOPT_AUTOREFERER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIEFILE => $cookie,
CURLOPT_COOKIEJAR => $cookie ,
CURLOPT_SSL_VERIFYPEER => 0 ,
CURLOPT_SSL_VERIFYHOST => 0
);
curl_setopt_array($ch, $options);
$kl = curl_exec($ch);
curl_close($ch);
echo $kl; // Final output after fetching
喜傑夫,你可以給整個PHP。我可以幫你解決它。 –
這是完整的PHP! – Jeff