테스트 사이트 - 개발 중인 베타 버전입니다

크롤링하는 기존 예제인데요 채택완료

GST1 3년 전 조회 2,711

//크롤링 불러오기 include_once("/g5/lib/simple_html_dom.php"); $colspan = 4;

$dom = new simple_html_dom; $dom -> load($cont);

        

$dom_div = $dom -> find('div.pdtWrap',0); if($dom_div) {     $dom_ul = $dom_div -> find('ul.pdtList',0);     if($dom_ul) {         $dom_li = $dom_ul -> find('div.pdtBox');     } }

 

 

크롤링 라이브러리를 불러오는건 에러 안나는데 선언하면 사이트 메뉴가 깨지는데 왜그런지 아시는분 계시나요??

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
세크티
3년 전

 </p>

<p>$dom = new simple_html_dom(); </p>

<p>

 

괄호 추가해보세요

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

G
GST1
3년 전
그래도 안되는데요 뭐설치해야하는 라이브러리같은게 있나요? apm7 로컬에서도
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in C:\APM_Setup\htdocs\simple_html_dom.php on line 77

Warning: file_get_contents(http://www.google.com/) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in C:\APM_Setup\htdocs\simple_html_dom.php on line 77
내용작성

안되더라구요
세크티
3년 전
$cont 가 혹시 url 인가요? allow_url_fopen이 off이면 file_get_contents가 안먹히기 때문에 curl로 html코드를 미리 가져와야 합니다.

[code]
include_once("/g5/lib/simple_html_dom.php");
$colspan = 4;

$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $cont);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);  
$contents = curl_exec($curl);  curl_close($curl);

$dom = new simple_html_dom();
$dom -> load($contents);
[/code]
G
GST1
3년 전
너무 감사드립니다. on으로 해도 file_get_contents 에러나오더라구요

댓글을 작성하려면 로그인이 필요합니다.

윤석렬
3년 전

; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On

; Whether to allow include/require to open URLs (like http:// or ftp://) as files. allow_url_include = On

 

풀어주니 로컬 apm7에서는 에러가 안나오네요

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

윤석렬
3년 전
PHP Version 5.5.17p1

 

Directive Local Value Master Value
allow_url_fopen Off Off

 

 

카페24 php 이렇게 되어있는데 안되는건가요??

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인