Skip to content

Instantly share code, notes, and snippets.

@Kyeongrok
Created July 13, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kyeongrok/eba4f2d931daa04b4f3e5f21d013a89d to your computer and use it in GitHub Desktop.
Save Kyeongrok/eba4f2d931daa04b4f3e5f21d013a89d to your computer and use it in GitHub Desktop.
function myFunction() {
  // 1. 페이지 불러오기
  var url = "http://finance.daum.net/item/main.daum?code=005930";
  var response = UrlFetchApp.fetch(url);
  var content = response.getContentText("UTF-8");
  
  // 2. 정규식으로 데이터 읽어오기
  var title = content.match(/<em class="screen_out">(.*?)<\/em>/);
  
  // 3. 시트에 읽어온 데이터 출력하기
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet1=ss.getSheetByName("Sheet1");
  sheet1.getRange(1,1).setValue("Page Title"); // Page title
  sheet1.getRange(1,2).setValue(title[1]); // Title
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment