정규식 잘하시닌분조와주세요
본문
네이버 파싱해서 보드에넣고있는데요
파싱은됫는데 파싱된 데이터를 입력하려고보니가 안되서질문드림니다
아래소스는 파싱된 페이지에서 소스보기했을때 저렇게나오는데요
입력을하려고하니가 앞에 첫줄(빨간색부분)만 들어가고 나머지는
안들어가지네요
<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1"><br><img src="http://postfiles13.naver.net/122933_02.jpg?type=w1"><br><img src="http://postfiles6.naver.net/122935_03.jpg?type=w1"><br><img src="http://postfiles2.naver.net/122938_04.jpg?type=w1"><br><img src="http://postfiles9.naver.net/122941_05.jpg?type=w1"><br><img src="http://postfiles1.naver.net/122942_06.jpg?type=w1"><br><img src="http://postfiles3.naver.net/122944_07.jpg?type=w1"><br><img src="http://postfiles9.naver.net/122946_08.jpg?type=w1"><br>
이거는 파싱할때 쓴소스임니다
$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);
preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>"; //echo 햇을경우 잘보임......
$newpost[wr_content] = "$img2"; // 보드에 입력할때 첫줄만들가짐,..
답변 6
$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);
preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>";
$newpost[wr_content] .= "$img2";
}
$newpost[bo_table] = "free";
$newpost[wr_subject] = "$it_name";
$newpost[wr_link1] = "$url";
$newpost[mb_id] = 'admin';
$result = m3post($newpost);
$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);
preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>";
$newpost[wr_content] .= "$img2";
}
$newpost[bo_table] = "free";
$newpost[wr_subject] = "$it_name";
$newpost[wr_link1] = "$url";
$newpost[mb_id] = 'admin';
$result = m3post($newpost);
$newpost[wr_content] =
"$img2"
;
// 보드에 입력할때 첫줄만들가짐,..
$newpost[wr_content] .= "$img2";
로 하셔야..하는게 아닐까요
해봤는데 똑같네요,ㅜ.ㅜ
맨앞에 빨간부분은
<img src=
"http://postfiles1.naver.net/122930_01.jpg?type=w1"
><br>
입니다.
<img src=
"http://postfiles1.naver.net/122930_01.jpg?type=w1"
><br>
<img src=
"http://postfiles1.naver.net/122930_01.jpg?type=w1"
><br>
이렇게나오네요... 아래소느도한번봐주실래요 아래거를바궈보니 위에이미지를 다가져오는데
게시글이 이미지숫자만큼 작성됨니다 이미지가 10개면 게시글 10개작성됨니다.
현제입력부분...
$row = sql_fetch("select count(*) as cnt from {$write_table} where wr_link1 = '$wr_link1'");
if($row['cnt']) return false;
아래거로했을때는 이미지를 전부다가져오나 게시글이 이미지숫자만큼 작성되서 올라가네요
//$row = sql_fetch("select count(*) cnt from {$write_table} where wr_content = '$wr_content'");
//if($row['cnt']) return false;
같은상황이네요...
$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>";
}
$newpost[bo_table] = "free";
$newpost[wr_subject] = "$it_name";
$newpost[wr_content] = "$img2";
$newpost[wr_link1] = "$url";
$newpost[mb_id] = 'admin';
$result = m3post($newpost);
?>
혹시 저기 $img2를 $wr_1 부터 10까지 이미지1개씩 따로따로 불러올려면 foreach을어덯게 작성해야되는지요?
아니면 다른방법이라도....
아래처럼 1개식잘라서 넣으면들어갈거같아서요
$newpost[wr_1] = "$img_1";
$newpost[wr_2] = "$mg_2";
$newpost[wr_3] = "$img_3";
$newpost[wr_4] = "$mg_4";
$newpost[wr_5] = "$mg_5";
$pattern = '@<img src="http://postfiles.*\?type=w1">@';
$contents = file_get_contents($url);
preg_match($pattern, $contents, $match);
$newpost[wr_content] = $match[0];