티스토리 뷰

etc/강의

구글 검색결과 주소 크롤링 코드

KyeongRok Kim 2017. 4. 16. 13:44
구글 검색결과 주소 크롤링 코드
 
var client = require('cheerio-httpcli');

var wordRegexp1 = {
  "word":"서울대입구 전세",
  "regexp":/http.{20}/g,
}

var wordRegexp2 = {
  "word":"신사역 전세",
  "regexp":/http.{20}/g,
}

var wordRegexp3 = {
  "word":"방배역 전세",
  "regexp":/http.{20}/g,
}



var wordRegexpList = [];
wordRegexpList.push(wordRegexp1);
var printHttpRequest = (address, word, regexp)=>client.fetch(
  address
  ,
  ,(err, $, res, body)=>{
    var aList = $("div.rc").find(".r").find("a");
    for(var i = 0 ; i < aList.length ; i++){
        console.log($(aList[i]).attr("href"));
    }
    //console.log(item);
  }
)

var printHttpRequest2 = (address)=>client.fetch(
  address
  ,{}
  ,(err, $, res, body)=>{
    console.log(body);
  }
)

console.log(wordRegexpList);

for(var wordRegexp of wordRegexpList){
  printHttpRequest("http://www.google.com/search", wordRegexp['word'], wordRegexp['regexp']);
}


var searchResultList = [
  "http://bdsit.com/bbs/board.php?bo_table=land&wr_id=1752",
  "http://krksap.tistory.com/294",
  "https://www.youtube.com/watch?v=MG48cOQ1YKU",
  "http://blog.daum.net/53sup/72",
  "http://blog.naver.com/PostView.nhn?blogId=kgjjun&logNo=162154831&categoryNo=1&parentCategoryNo=-1&viewDate=&currentPage=&postListTopCurrentPage=&isAfterWrite=true",
  "http://seoul.dosimong.com/toadhouse/list_view.php?noo=2220",
  "http://www.okbang.co.kr/info_view.php?idx=2508",
  "http://www.r114.co.kr/z/real/m_dong.asp?only=0&m_=5&g_=&type=m&type_m=j&type_g=C&type_cd=05%5E&addr1=%BC%AD%BF%EF%C6%AF%BA%B0%BD%C3&addr2=%B0%FC%BE%C7%B1%B8&addr3=%BA%C0%C3%B5%B5%BF",
  "http://www.r114.com/z/real/s_dong.asp?only=0&m_=2&g_=&type=s&type_g=A&type_cd=01%5E&addr1=%BC%AD%BF%EF%C6%AF%BA%B0%BD%C3&addr2=%B0%FC%BE%C7%B1%B8&addr3=%BA%C0%C3%B5%B5%BF&shin=&vill=&jigu=&mjong=1&aptcode=A01051510500068&aptname=%BC%AD%BF%EF%B4%EB%C0%D4%B1%B8%BE%C6%C0%CC%BF%F8",
  "http://speedroom.tistory.com/331",
]
console.log("----------------");
for(var item of searchResultList){
  printHttpRequest2(item);
}
 

 

end.

 

 

728x90
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함