이윰빌더에서 파싱기 사용 문의
2017.09.28 09:08
1,451
2
- - 짧은주소 : http://e3net.fineyes.com/bbs/?t=17q
본문
안녕하세요!
얼마전에 컴퓨터 공학과에 다니는 친구한테 파싱 이야기를 했더니
소스를 보내줬는데요, 이 소스를 이윰빌더에서 사용하려고 하니
오류가 뜨는것도 아니고 그냥 무반응이라서;;;
소스 어느 부분을 손봐야 할지 여쭤보고자 글을 올려봅니다.
이 소스를 준 친구는 현재 중국에 가 있는 상황입니다..ㅠㅠㅠ
sir로 가봐야할 문제일까요?
<meta charset="utf-8">
<?php
define('_INDEX_', true);
include_once('./_common.php');
include "lib/Snoopy.class.php";
$snoopy = new Snoopy;
if($snoopy->fetch("http://gall.dcinside.com/board/lists/?id=ib&page=2")){
// other methods: fetch, fetchform, fetchlinks, submittext and submitlinks
include "lib/simple_html_dom.php";
$html =new simple_html_dom(); //돔 객체 생성
$html->load($snoopy->results); // 로드 함수 호출하여 스누피 결과값 입력\
$lists=$html->find('tr[class=tb]'); // selector를 이용하여 요소값 인식
$pattern = "/<td\sclass=\"t_notice\">공지.+<\/tr>/"; //공지제거
$lists= preg_replace($pattern,"",$lists);
foreach($lists as $list){
$list = str_replace('a href="/','a href="http://gall.dcinside.com/', $list); //경로수정
//echo $list. "";// 리스트 출력
$htm = str_get_html($list); // 리스트에서 주소뽑기1
foreach($htm->find('a[class=icon_txt_n]') as $ctitle)
$newtitle = $ctitle ->plaintext;
foreach($htm->find('a') as $a){
$contents = test(utf8_decode($a->href)); //주소뽑기2
$pattern = array('/- dc official App/');
$conresult = mb_strimwidth(preg_replace($pattern,'- 이윰',$contents->plaintext),0,700,'');
}
}
}
else {
print "Snoopy: error while fetching document: ".$snoopy->error."\n";
}
//게시판 입력관련///////////////////////////////////////////////
function insert_write($newpost)
{
global $g5;
//게시판 테이블 정보
$bo_table = $newpost[bo_table];
if(!strlen($bo_table)) return FALSE; //bo_table 값이 지정되지 않았습니다.
$board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
if(!$board) return FALSE; //bo_table이 존재하지 않습니다.
//회원정보 및 권한 확인
$member = get_member($newpost[mb_id]);
if(!$member) return FALSE; //mb_id가 존재하지 않습니다.
//if($board[bo_write_level] > $member[mb_level]) return FALSE; //글쓰기 권한이 없습니다.
//카테고리 설정
$ca_name = $newpost[ca_name];
if ($ca_name && strpos($board[bo_category_list], $ca_name) === FALSE){
$category_list = $board[bo_category_list]."|".$ca_name;
$sql = " update {$g5['board_table']} set bo_category_list = '$category_list' where bo_table = '$bo_table' ";
sql_query($sql);
}
//변수 정리
$write_table = $g5[write_prefix].$bo_table;
$wr_num = get_next_num($write_table);
$ca_name = addslashes($ca_name);
$html = "html1";
$secret = "";
$mail = "";
$wr_subject = addslashes(trim($newpost[wr_subject]));
$wr_content = addslashes(trim($newpost[wr_content]));
if(!$wr_subject) return FALSE; //글 제목이 없습니다.
if(!$wr_content) return FALSE; //글 내용이 없습니다.
$mb_id = $member[mb_id];
$wr_password = $member[mb_password];
$wr_name = $board[bo_use_name] ? $member[mb_name] : $member[mb_nick];
$wr_email = $member[mb_email];
$wr_homepage = $member[mb_homepage];
for($i=1; $i<=10; $i++){
$wr = "wr_{$i}";
${$wr} = addslashes($newpost[$wr]);
}
$wr_link1 = $newpost[wr_link1];
$wr_link2 = $newpost[wr_link2];
//글 입력하기
$sql = " insert into $write_table
set wr_num = '$wr_num',
wr_reply = '',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$html,$secret,$mail',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = '" . rand(100, 200) . "',
wr_good = 0,
wr_nogood = 0,
mb_id = '$mb_id',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$wr_id = sql_insert_id();
sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' "); //부모 아이디에 UPDATE
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '$mb_id' ) "); //새글 INSERT
sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}' "); //게시글 1 증가
return array('bo_table' => $bo_table, 'wr_id' => $wr_id, 'sca' => $ca_name);
//return TRUE;
}
$timg = array('/img/1.png', '/2.png');
$ttitle = array('1', '2', '3');
$ttitle_cnt = sql_fetch(" select tp_cnt from tp_title_cnt ");
if (count($ttitle) > $ttitle_cnt['tp_cnt'])
sql_query(" update tp_title_cnt set tp_cnt = tp_cnt + 1 ");
if (count($ttitle) == ($ttitle_cnt['tp_cnt']+1))
sql_query(" update tp_title_cnt set tp_cnt = 0 ");
//$newpost[mb_id], $newpost[bo_table], $newpost[wr_subject], $newpost[wr_content] 값만 지정하고,
//insert_write($newpost); 라고 실행시키면 글이 해당 게시판에 올라갑니다.
$newpost = array(
'mb_id' => 'admin',
'bo_table' => $_REQUEST['board_type'],
'wr_subject' => $newtitle,
'wr_content' => $conresult
);
$result = insert_write($newpost);
//게시판 입력관련 끄으으읕///////////////////////////////////////////////
//링크안에 내용 구하기 a->href 상세데이터를 파싱해서 상세데이터를 리턴함
function test($link) {
$snoopy = new Snoopy;
$detail_content;
if(strstr($link, 'javascript')) return false;
if($snoopy->fetch($link)){
// other methods: fetch, fetchform, fetchlinks, submittext and submitlinks
$html =new simple_html_dom(); //돔 객체 생성
$html->load($snoopy->results); // 로드 함수 호출하여 스누피 결과값 입력\
//
$contents=$html->find('div[class=s_write]'); // selector를 이용하여 요소값 인식
foreach($contents as $list){
$detail_content = $list;
//경로수정
//$list = str_replace('a href="/','a href="http://gall.dcinside.com/', $list); //경로
}
} //snoop use check
return $detail_content;
}
?>
0
로그인 후 평가 가능합니다.
-
인졀미
- 회원등급 : 지하계 / Level 3
포인트 10
경험치 927
[레벨 3] - 진행률
55%
- 가입일 : 2016-10-26 09:12:38
- 서명 : 미입력
- 자기소개 : 미입력
댓글목록 2
이윰MOUNT님의 댓글
인절미님 안녕하세요.
소스만 봐서는 모르겠습니다. 이거 분석하고 문제점을 해결하는 것만으로도 많은 시간이 걸릴수 있으며, 단순히 응대를 해 드릴수 있는 부분이 아닌점 양해 해 주시기 바랍니다.
감사합니다.
축하합니다. 첫댓글 포인트 6포인트를 획득하였습니다.
공미니님의 댓글
좋은정보감사합니다