snoopy와 curl 동일한 url을 파싱하는데.. snoopy가 훨씬 빠른 듯
본문
https://www.facebook.com/sweety.pmy/posts/132697864351424
페이지에서 title을 파싱하는 rule를 적용하면...
<?php
include "../lib/Snoopy/Snoopy.class.php";
$snoopy = new Snoopy;
$url = 'https://www.facebook.com/sweety.pmy/posts/132697864351424';
$snoopy->setcookies();
$snoopy->fetch($url);
preg_match('~pageTitle">(.*?)<\/title>~is', $snoopy->results, $text);
echo $text[1];
?>
<?php
$agent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2';
$url = 'https://www.facebook.com/sweety.pmy/posts/132697864351424';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$content = curl_exec($ch);
curl_close($ch);
preg_match('~pageTitle">(.*?)<\/title>~is', $content, $text);
echo $text[1];
?>
동일한 파싱룰을 가지고 snoopy와 curl으로 처리해봤는데
snoopy가 curl 보다 2배정도 빠른 듯 하네요
잘못 된 건지???
파싱할 결과 ==> 박민영 - #cosmopolitankorea ♥️ | Facebook