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

정규식 잘하시닌분조와주세요 채택완료

sahara 10년 전 조회 3,987

네이버 파싱해서 보드에넣고있는데요

파싱은됫는데 파싱된 데이터를 입력하려고보니가 안되서질문드림니다

 

아래소스는 파싱된 페이지에서 소스보기했을때 저렇게나오는데요 

입력을하려고하니가 앞에 첫줄(빨간색부분)만 들어가고 나머지는 

안들어가지네요

 

</span><span style="font-size: 10pt; line-height: 1.5; color: rgb(255, 0, 0);"><img src="<a href="<a href="http://postfiles1.naver.net/122930_01.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles1.naver.net/122930_01.jpg?type=w1</a>"><a href="http://postfiles1.naver.net/122930_01.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles1.naver.net/122930_01.jpg?type=w1</a></a>">
</span><span style="font-size: 10pt; line-height: 1.5;"><img src="</span><a href="<a href="http://postfiles13.naver.net/122933_02.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles13.naver.net/122933_02.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles13.naver.net/122933_02.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles13.naver.net/122933_02.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles6.naver.net/122935_03.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles6.naver.net/122935_03.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles6.naver.net/122935_03.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles6.naver.net/122935_03.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles2.naver.net/122938_04.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles2.naver.net/122938_04.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles2.naver.net/122938_04.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles2.naver.net/122938_04.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles9.naver.net/122941_05.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles9.naver.net/122941_05.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles9.naver.net/122941_05.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles9.naver.net/122941_05.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles1.naver.net/122942_06.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles1.naver.net/122942_06.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles1.naver.net/122942_06.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles1.naver.net/122942_06.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles3.naver.net/122944_07.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles3.naver.net/122944_07.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles3.naver.net/122944_07.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles3.naver.net/122944_07.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
<img src="</span><a href="<a href="http://postfiles9.naver.net/122946_08.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles9.naver.net/122946_08.jpg?type=w1</a>" style="font-size: 10pt; line-height: 1.5;"><a href="http://postfiles9.naver.net/122946_08.jpg?type=w1" target="_blank" rel="noopener noreferrer">http://postfiles9.naver.net/122946_08.jpg?type=w1</a></a><span style="font-size: 10pt; line-height: 1.5;">">
</span><span style="font-size: 9pt; line-height: 1.5; font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif;">​</span><span style="font-size: 10pt; line-height: 1.5;">

 

이거는 파싱할때 쓴소스임니다

 

</span><b style="font-size: 10pt; line-height: 1.5;"><span class="html-tag" style="font-size: 9pt; font-family: 나눔고딕코딩, NanumGothicCoding, sans-serif; line-height: normal; white-space: pre-wrap; color: rgb(255, 0, 0);">​</span></b><span style="font-size: 10pt; line-height: 1.5;">​</span><span style="font-size: 10pt; line-height: 1.5;">$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";</span></p><p>$contents = file_get_contents($url);</p><p>preg_match_all($pattern, $contents, $match);</p><p>foreach($match[0] as $key => $img) {</p><p>$val = substr($img, 0, -1);</p><p><span style="font-size: 10pt; line-height: 1.5;">$img2 = '<img src="'.$img.'">'."
";    //echo 햇을경우 잘보임......</span></p><p> </p><p>$newpost[wr_content] = "$img2";           // 보드에 입력할때 첫줄만들가짐,..</p><p><span style="font-size: 10pt; line-height: 1.5;"> </span><span style="font-size: 10pt; line-height: 1.5;">

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

답변 6개

채택된 답변
+20 포인트
P
10년 전

</p><p><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";</span><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);"> </span></p><p><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$contents = file_get_contents($url); </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">preg_match_all($pattern, $contents, $match); </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">foreach($match[0] as $key => $img) { </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$val = substr($img, 0, -1); </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$img2 = '<img src="'.$img.'">'."
";</span></p><p><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$newpost[wr_content] .= "$img2"; </span></span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">}</span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$newpost[bo_table] = "free"; </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$newpost[wr_subject] = "$it_name"; </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$newpost[wr_link1] = "$url"; </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$newpost[mb_id] = 'admin'; </span><br style="text-align: justify; line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(236, 237, 239);"><span style="text-align: justify; color: rgb(0, 0, 0); line-height: 20.39px; font-family: 돋움, dotum, helvetica; font-size: 12px; background-color: rgb(255, 255, 255);">$result = m3post($newpost); </span></p><p>
 

 

$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);  

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

답변에 대한 댓글 1개

s
sahara
10년 전
이거때문에 8시간헤멧는데 ㅋㅋㅋㅋ. 감사함니다. 늙어서 해볼라니가 어지럽네여,ㅋㅋ

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

10년 전

$pattern = '@<img src="http://postfiles">http://postfiles.*\?type=w1">@';

$contents = file_get_contents($url);

preg_match($pattern, $contents, $match);

$newpost[wr_content] = $match[0]; 

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

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

s
10년 전

같은상황이네요...

 

$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";

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

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

s
10년 전

맨앞에 빨간부분은 <img src="http://postfiles1.naver.net/122930_01.jpg?type=w1" style="color: blue !important;">http://postfiles1.naver.net/122930_01.jpg?type=w1"><br>

입니다.​


<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1" style="color: blue !important;">http://postfiles1.naver.net/122930_01.jpg?type=w1"><br>

<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1" style="color: blue !important;">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;  

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

답변에 대한 댓글 3개

먼지손
10년 전
$row = sql_fetch("select count(*) as cnt from {$write_table} where wr_link1 = '$wr_link1'");
if($row['cnt']) return false;
이건 입력과는 관계없어 보이구요.
foreach()문의 블럭이 insert 이후에 닫히는 모양이군요. insert 이전으로 닫는괄호(})를 옮기셔야 할겁니다.
s
sahara
10년 전
$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_content] .= "$img2";
$newpost[wr_link1] = "$url";
$newpost[mb_id] = 'admin';
$result = m3post($newpost);
}
?>
맨아래 닫히게해놧는데이리저리옴겨볼게요
P
PWneo
10년 전
foreach가 m3post(); 뒤에 닫기네요. newpost 가 시작되는줄 위로 올리시면 되겠네요
$newpost[wr_content] = "$img2";
이 라인은 지우시구요

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

s
10년 전

해봤는데 똑같네요,ㅜ.ㅜ

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

답변에 대한 댓글 1개

P
PWneo
10년 전
맨앞의 빨간게 어떤부분이죠?

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

P
10년 전

$newpost[wr_content] = "$img2";           // 보드에 입력할때 첫줄만들가짐,..

$newpost[wr_content] .= "$img2";

 

로 하셔야..하는게 아닐까요 

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

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

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

로그인