{
"success": true,
"start": 0,
"limit": 20,
"total": 99,
"posts": [
{
"idx": 1,
"bid": "notice",
"title": "테스트 공지",
},
{
"idx": 2,
"bid": "free",
"title": "aaaaa",
},
{
"idx": 44,
"bid": "qna",
"title": "what?",
}
]
}
요런 html로 정보를 받고 있습니다.
include "simple_html_dom.php";
이걸 써서 파싱을 하라고 하는데
예를 들어 notice 의 글만 가져 올려고 하면 어떻게 해야 할까요?
|
답변 4개 / 댓글 3개
채택된 답변
+20 포인트
Copy
$tmp_data = '';
$url = "URL주소";
$tmp_data = file_get_contents_curl($url);
$tmp_data = json_decode($tmp_data);
$data = array();
foreach($tmp_data['posts'] as $k => $v){
if($v['bid'] == 'notice') $data[] = $v;
}
print_r($data);
대략 이정도 일듯 하네요.
api로 거르는게 아니면 notice만 나온 페이지의 데이터부분 받는곳은 크롬 개발자도구로 열어서
그쪽 url로 들어가시면 notice만 나옵니다. 그게 없다면 안됩니다.
답변을 작성하려면 로그인이 필요합니다.
Array ( )
이렇게만 화면에 나옵니다.