레고 장터 실시간 업데이트 JSP 소스

2011. 3. 8. 16:1498. 정리전 - 취미/09. LEGO TECHNIC

레고 장터 실시간 업데이트 JSP 소스
(브릭인사이드 + 네이버카페  + 다음카페 종합)


<%@ page import="java.io.*, java.util.*, java.text.*, java.io.*, java.net.*"%>
<%@ page contentType="text/html; charset=euc-kr"%>

<script language="javascript">
  function linkBrickinside() {
    window.open('http://www.brickinside.com/NeoBoard.php?Db=SellBoard', '_blank');
  } 
  function linkNaver() {
    window.open('http://cafe.naver.com/ArticleList.nhn?search.clubid=11156622&search.menuid=14&search.boardtype=L', '_blank');
  } 
  function linkDaum() {
    window.open('http://cafe329.daum.net/_c21_/bbs_list?grpid=Vytu&fldid=180u&isRedirected=true', '_blank');
  } 
  function linkJoonggoNara() {
    window.open('http://cafe.naver.com/ArticleList.nhn?search.clubid=', '_blank');
  }
</script>

<%!
  public String callValue(String y, String m, String d, String strURL) {
    /*-----------------------------------------------*/
    //                    검색 단어
    /*-----------------------------------------------*/
    /**/          String SEARCH = "8043";          /**/
    /*-----------------------------------------------*/
    /*-----------------------------------------------*/

    URL myURL;
    InputStream is;
    BufferedReader br;
    String data;
    StringBuffer sb1 = new StringBuffer();
 
    try {
      // URL을 표시하는 String으로 URL클래스 객체생성.
      myURL = new URL(strURL);
 
      // 생성된 URL클래스로 URL이 지시하는 서버와 접속후.
      // 해당 스트림을 넘겨준다.
      is = myURL.openStream();
 
      // 입력 스트림을 이용하여 BufferedReader 클래스 객체를 생성.
      br = new BufferedReader(new InputStreamReader(is));
 
      boolean brBool = false;
      int brCnt = 0;
      // 입력 스트림에서 데이터가 완료될때까지 데이터를 읽어서 화면에 표시.
      while ((data = br.readLine()) != null) {
        // 날짜
        if (data.indexOf(y+"/"+m+"/"+d) > -1) {
            data = data.replaceAll(y+"/"+m+"/"+d, "<span style='font: bold 9px verdana, arial, helvetica, sans-serif; color:red;'>" + y+"/"+m+"/"+d + "</span>");
        } else if (data.indexOf(y+"."+m+"."+d) > -1) {
            data = data.replaceAll(y+"."+m+"."+d, "<span style='font: bold 9px verdana, arial, helvetica, sans-serif; color:red;'>" + y+"/"+m+"/"+d + "</span>");
        } else if (data.indexOf(y.substring(2,4)+"."+m+"."+d) > -1) {
            data = data.replaceAll(y+"."+m+"."+d, "<span style='font: bold 9px verdana, arial, helvetica, sans-serif; color:red;'>" + y+"/"+m+"/"+d + "</span>");
        } else if (data.indexOf("<td class=\"date\" nowrap=\"nowrap\">") > -1 && data.indexOf(":") > -1) {
            data = data.replaceAll("<td class=\"date\" nowrap=\"nowrap\">", "<td class=\"date\" nowrap=\"nowrap\" style='font: bold 9px verdana, arial, helvetica, sans-serif; color:red;'>");
        } else if (data.indexOf(SEARCH) > -1) {
            data = "<span style='font: bold 15px verdana, arial, helvetica, sans-serif; color:red;'>" + data + "</span>";
        }

        //브릭인사이드
        if (brBool) {
            brCnt++;
            if (brCnt > 31) {
                brBool = false;
            }
            continue;
        }
        if (data.indexOf("<TH HEIGHT=18 class=hd WIDTH='") > -1) continue;
        if (data.indexOf("<TD class=tc style='background-color:#DAD8D8'><img src=\"/NeoBoard/icon/new_notice.gif\" width=\"12\" height=\"12\"></TD>") > -1) {
            brBool = true;
            continue;
        }
        if (data.indexOf("<div class=\"pers_nick_area\">") > -1) continue;

        // 토이아제
        if (data.indexOf("/product.html?branduid=") > -1) continue;
       
        // 네이버 중고나라
        if (data.indexOf("list-i-sellout") > -1) continue;
        if (data.indexOf("삽니다") > -1) { sb1.append("삽니다"); continue; }
       
        sb1.append(data + "\n");
      }
 
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("url = " + strURL);
      System.out.println("ViewURL--> made in parana");
    }
    return sb1.toString().trim();
  }
%>

<div class=unc-index>
 <div class=full>
  <META HTTP-EQUIV="REFRESH" CONTENT="60; URL=http://donzbox.com">
<%
  SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
  String today = sdf.format(new Date());
  String y = today.substring(0, 4);
  String m = today.substring(4, 6);
  String d = today.substring(6, 8);

  String txt = "";
 
  // Naver 중고나라 page1
//txt = callValue(y,m,d, "http://cafe.naver.com/ArticleList.nhn?search.clubid=10050146&search.menuid=379&search.boardtype=L");
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleSearchList.nhn?search.media=0&search.searchdate=all&search.searchBy=0&search.viewtype=title&search.headid=0&search.query=%B7%B9%B0%ED&search.menuid=379&search.sortBy=date&userDisplay=15&search.clubid=10050146&search.page=1");
  txt = "<TABLE><tbody>" + txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">"), txt.indexOf("<div class=\"prev-next\">") -1471);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-safecomm\" readonly=\"readonly\" title=\"안전거래\">", "(안거)");
  String txtTmp = txt;

  // Naver 중고나라 page2
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleSearchList.nhn?search.media=0&search.searchdate=all&search.searchBy=0&search.viewtype=title&search.headid=0&search.query=%B7%B9%B0%ED&search.menuid=379&search.sortBy=date&userDisplay=15&search.clubid=10050146&search.page=2");
  txt = txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">") +36, txt.indexOf("<div class=\"prev-next\">") -1471);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-safecomm\" readonly=\"readonly\" title=\"안전거래\">", "(안거)");
  txtTmp = txtTmp + txt;

  // Naver 중고나라 page3
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleSearchList.nhn?search.media=0&search.searchdate=all&search.searchBy=0&search.viewtype=title&search.headid=0&search.query=%B7%B9%B0%ED&search.menuid=379&search.sortBy=date&userDisplay=15&search.clubid=10050146&search.page=3");
  txt = txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">") +36, txt.indexOf("<div class=\"prev-next\">") -1471);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-safecomm\" readonly=\"readonly\" title=\"안전거래\">", "(안거)");
  txtTmp = txtTmp + txt;

  // Naver 중고나라 page4
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleSearchList.nhn?search.media=0&search.searchdate=all&search.searchBy=0&search.viewtype=title&search.headid=0&search.query=%B7%B9%B0%ED&search.menuid=379&search.sortBy=date&userDisplay=15&search.clubid=10050146&search.page=4");
  txt = txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">") +36, txt.indexOf("<div class=\"prev-next\">") -1);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-safecomm\" readonly=\"readonly\" title=\"안전거래\">", "(안거)");
  txtTmp = txtTmp + txt;
 
  out.println("N중<div id=chatWindow style='width:100%; height:100px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txtTmp);
  out.println("</div>"); 
  
  // Brickinside
  txt = callValue(y,m,d, "http://www.brickinside.com/NeoBoard.php?Db=SellBoard");
  txt = txt.substring(
    txt.indexOf("<!-- Private Lock Icon -->") + 127 ,
    txt.indexOf("font-family:돋움'>김성완</FONT>")-354
    );
  txt = txt + "</TABLE></TD></TABLE></FORM>";
  txt = txt.replaceAll("OnPrivateHandle", "linkBrickinside");
  txt = txt.replaceAll("<IMG SRC=\"/NeoBoard/icon/board_lock.gif\" BORDER=0 WIDTH=22 HEIGHT=19 ALT=' 가입 필요 '>", "");
  txt = txt.replaceAll("<IMG SRC=\"/NeoBoard/icon/list_head.gif\" BORDER=0 align=top>", "");
  txt = txt.replaceAll("<IMG SRC=\"/NeoBoard/icon/adm_new.gif\" BORDER=0>", "");
  txt = txt.replaceAll("<IMG SRC='/NeoBoard/icon/new_icon.gif' alt='New article' align=top>", "");
  txt = txt.replaceAll("onMouseOver=\"window.status='Member Login'", "");
  txt = txt.replaceAll("&nbsp;&nbsp;<IMG SRC=\"/NeoBoard/icon/key.gif\" BORDER=0 WIDTH=11 HEIGHT=10 ALT='비밀문서' align=top>&nbsp;", "");
  txt = txt.replaceAll("<A HREF='NeoView.php?", "<A HREF='http://www.brickinside.com/NeoView.php?");
  out.println("B<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");

  // Naver
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleList.nhn?search.clubid=11156622&search.menuid=14&search.boardtype=L");
  txt = "<TABLE><tbody>" + txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">"), txt.indexOf("<div class=\"prev-next\">") -1);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-safecomm\" readonly=\"readonly\" title=\"안전거래\">", "(안거)");
  out.println("N브<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");
 
  // Daum 제품
  txt = callValue(y,m,d, "http://cafe329.daum.net/_c21_/bbs_list?grpid=Vytu&fldid=GLFn");
  txt = "<TABLE><tbody>" + txt.substring(txt.indexOf("<!-- 공지기능 적용끝  -->"), txt.indexOf("<!-- end bbsList -->"));
  txt = txt.replaceAll("<a href=\"/_c21_/bbs_read", "<a target='_blank' href=\"http://cafe329.daum.net/_c21_/bbs_read");
  out.println("D제<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");

  // Daum 부품
  txt = callValue(y,m,d, "http://cafe329.daum.net/_c21_/bbs_list?grpid=Vytu&fldid=180u&isRedirected=true");
  txt = "<TABLE><tbody>" + txt.substring(txt.indexOf("<!-- 공지기능 적용끝  -->"), txt.indexOf("<!-- end bbsList -->"));
  txt = txt.replaceAll("<a href=\"/_c21_/bbs_read", "<a target='_blank' href=\"http://cafe329.daum.net/_c21_/bbs_read");
  out.println("D부<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");

  // 브마
  txt = callValue(y,m,d, "http://www.brickmaniax.co.kr/shop/goods/goods_list.php?category=009");
  txt = txt.substring(txt.indexOf("<!-- 상품 리스트 -->"), txt.indexOf("<form name=frmCharge method=post>") -8);
  txt = txt.replaceAll("onmouseover=\"Div_type('list');Div_clone(event);\"", "");
  txt = txt.replaceAll("<img src='../data/skin/interactive_C/img/icon/good_icon_new.gif'>", "");
  txt = txt.replaceAll("<img src='../data/skin/interactive_C/img/icon/good_icon_sale.gif'>", "");
  txt = txt.replaceAll("<img src='../data/skin/interactive_C/img/icon/good_icon_popular.gif'>", "");
  txt = txt.replaceAll("<img src='../data/skin/interactive_C/img/icon/good_icon_recomm.gif'>", "");
  txt = txt.replaceAll("<img src='../data/", "<img src='http://www.brickmaniax.co.kr/shop/data/");
  txt = txt.replaceAll("<img src=\"/shop/data/", "<img src=\"http://www.brickmaniax.co.kr/shop/data/");
  txt = txt.replaceAll("<img src=", "<img border=0 src=");
  txt = txt.replaceAll("<a href=\"../goods/" , "<a href=\"http://www.brickmaniax.co.kr/goods/");
  txt = txt.replaceAll("<td align=center valign=top width=\"25%\">", "<td align=center valign=top>");
  out.println("BM<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");
 
  // 토아
  txt = callValue(y,m,d, "http://www.toyaje.com/shop/shopbrand.html?xcode=025&type=O");
  txt = txt.replaceAll("href=\"/", "href=\"http://www.toyaje.com/");
  txt = txt.replaceAll("href=\"./", "href=\"http://www.toyaje.com/");
  txt = txt.replaceAll("src=\"/", "src=\"http://www.toyaje.com/");
  txt = txt.replaceAll("src=\"./", "src=\"http://www.toyaje.com/");
  txt = txt.replaceAll("this.src='/images/", "this.src='http://www.toyaje.com/images/");
  txt = txt.replaceAll("<dt class=\"blind\">상품 이미지</dt>", "");
  txt = txt.replaceAll("<dt class=\"blind\">상품명</dt>", "");
  txt = txt.replaceAll("<dt class=\"price-tit\">상품가격</dt>", "");
  txt = txt.replaceAll("<dt class=\"mileage-tit\">적립금</dt>", "");
  txt = txt.replaceAll("<dd class=\"mileage\"><span>1%</span></dd>", "");
  txt = txt.replaceAll("<dt class=\"blind\">자세히보기</dt>", "");
  txt = txt.replaceAll("<hr />", "");
  String tmp1 = txt.substring(0, txt.indexOf("<div id=\"header\">") -1);
  String tmp2 = txt.substring(txt.indexOf("<ul class=\"plist-comm items\">"), txt.indexOf("<div id=\"footer\">") -1);
  txt = tmp1
      + "<style type=\"text/css\"><!-- li{float:left; overflow:auto; list-style:none; display:inline;} --></style>"
      + tmp2;
  out.println("TA<div id=chatWindow style='width:100%; height:90px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");

  // 작콩
  txt = callValue(y,m,d, "http://www.jbean.co.kr/front/php/category.php?cate_no=329&sort_method=5#normal_list");
  txt = txt.substring(txt.indexOf("굴림;\">신상품</a>") +385, txt.indexOf("<img src='http://img0001.echosting.cafe24.com/front/type_b/image/common/bul_06_back.gif'") -377);
  txt = txt.replaceAll("height=\"220\" width=\"220\">", ">");
  txt = txt.replaceAll("220\" width=\"220\"  style", "100\" width=\"100\"  style");
  out.println("JB<div id=chatWindow style='width:100%; height:100px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");
           
  // D 몽실이
  txt = callValue(y,m,d, "http://cafe.naver.com/ArticleList.nhn?search.clubid=22316565&search.menuid=55&search.boardtype=L");
  txt = "<TABLE><tbody>" + txt.substring(txt.indexOf("<div class=\"article-board m-tcol-c\">"), txt.indexOf("<div class=\"prev-next\">") -1);
  txt = txt.replaceAll("<a href='/ArticleRead.nhn", "<a target='_blank' href='http://cafe.naver.com/ArticleRead.nhn");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-img\" readonly=\"readonly\">", "");
  txt = txt.replaceAll("<input type=\"text\" class=\"list-i-new\" readonly=\"readonly\">", "");
  out.println("D몽<div id=chatWindow style='width:100%; height:80px; overflow:auto; background:#f4f4f4; padding:0px'>");
  out.println(txt);
  out.println("</div>");
   
%>

 </div>
</div>