Created
December 12, 2013 02:47
-
-
Save ikemonn/7922485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
var Yamashita = getYamashita(); | |
var greatKnowlege = getGreatKnowlege(); | |
sendMsg(Yamashita + greatKnowlege); | |
} | |
function sendMsg(msg) { | |
var roomID = 'Room idを書く'; | |
var cw = ChatWorkClient.factory({token: 'トークンを書く'}); | |
cw.sendMessage({room_id: roomID, body: msg}); | |
} | |
function getYamashita() { | |
var objSpreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var objSheet = objSpreadsheet.getActiveSheet(); | |
var objRange = objSheet.getRange("A1"); | |
return objRange.getValue(); | |
} | |
function getGreatKnowlege() { | |
//情報を取得するサイト | |
var url = "http://ja.uncyclopedia.info/wiki/%E7%89%B9%E5%88%A5:%E3%81%8A%E3%81%BE%E3%81%8B%E3%81%9B%E8%A1%A8%E7%A4%BA"; | |
var response = UrlFetchApp.fetch(url); | |
//正規表現で取得するコンテンツを指定 | |
var myRegexp = /<p><b>([\s\S]*?)<\/p>/i; | |
var match = myRegexp.exec(response.getContentText()); | |
var contents = match[1]; | |
//不要なタグを除く | |
contents = contents.replace(/<([\s\S]*?)>/g, ""); | |
return contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment