메애기 사이트 처음 봤는데 왤케 고트임

정말 마이너한 수요라서 절대 안나오겠지만 직업필터도 있으면 너무 좋을 듯

그리고 API 초창기에 잠깐 풀렸던, 다른 월드의 내 캐릭터 보기도 다시 지원되면 하는 바램


싱귤러 포인트 망토 예쁜데 요건 안보여서 아쉽더라 마찬가지로 API 쪽에서 요런 요소 지원은 앞으로도 없을 것 같음


요즘은 매주 딸농 45회, 펀치킹 15회씩 도는중

+ 라라 목초지 관리시트 자랑. 리부트도 열심히 키웠는데, 이젠 딸농이랑 펀치킹정도 밖에 안하는듯

투력이랑 레벨은 멥지지 웹 크롤링으로 자동완성(보수중). 구글시트 스크립트에서 이런 것도 되는 게 신기했음. 그런데 이젠 메애기.com에서 다 보여서 살짝 쓸모없어졌을지도.


오늘의 라라자랑 끝




++ 덧글 내용 중 전투력 및 레벨 자동얻기에 관한 내용에 대해 추가 작성


상세보기(접기)

위 스샷에서처럼 2열의 캐릭터이름을 이용해서, 6열에는 전투력, 7열에는 레벨을 자동으로 넣을 수 있도록 하였음.

fetchCharacterStats 함수는 2행(D,E,F, ...) 모든 캐릭터의 전투력을 얻어 6행 칸을 채워주는 함수. 전투력 얻기 버튼에 할당해주면 되고

fetchCharacterLevels 함수는 2행(D,E,F, ...) 모든 캐릭터의 레벨을 얻어 7행 칸을 채워주는 함수. 레벨 얻기 버튼에 할당해주면 된다.


캐릭터 이름으로 캐릭터 코드(ocid)를 얻고, ocid를 통해 전투력 또는 레벨을 얻어야 하는 구조로 되어있다는 점 참고.


아무래도 구글시트에서 작동하는거다보니까 느린감이 없지않아 있음.



// Nexon API Key

var apiKey = "넥슨 API 발급받아서 여기 넣기";


/** Get ocid */

function fetchCharacterID(characterName) {

  var idUrl = "https://open.api.nexon.com/maplestory/v1/id?character_name="; + encodeURIComponent(characterName);

  var options = {

    "method": "get",

    "headers": {

      "x-nxopen-api-key": apiKey,

      "accept": "application/json"

    },

    "muteHttpExceptions": true

  };


  try {

    var idResponse = UrlFetchApp.fetch(idUrl, options);

    var idJson = JSON.parse(idResponse.getContentText());

    if (idResponse.getResponseCode() === 200) {

      var ocid = idJson.ocid;

      return ocid; // ocid 반환

    } else {

      Logger.log("API 응답 에러: " + idResponse.getContentText());

      return null;

    }

  } catch (error) {

    Logger.log("API 호출 실패: " + error.toString());

    return null;

  }

}


/** Get Power */

function fetchCharacterStats() {

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

  var range = sheet.getRange("D2:BZ2"); // D2부터 BZ2까지 셀 범위 설정

  var characters = range.getValues()[0]; // 첫 번째 행의 모든 값을 배열로 가져옴


  for (var i = 0; i < characters.length; i++) {

    var characterName = characters[i];

    if (characterName === "") continue; // 셀이 비어있으면 건너뛰기


    var ocid = fetchCharacterID(characterName); // 개별 캐릭터 이름으로 ocid 가져오기

    if (!ocid) {

      sheet.getRange(6, 4 + i).setValue("ocid 가져오기 실패"); // 6번 행, 적절한 열에 기록

      continue;

    }


    var statUrl = "https://open.api.nexon.com/maplestory/v1/character/stat?ocid="; + encodeURIComponent(ocid);

    var options = {

      "method": "get",

      "headers": {

        "x-nxopen-api-key": apiKey,

        "accept": "application/json"

      },

      "muteHttpExceptions": true

    };


    try {

      var statResponse = UrlFetchApp.fetch(statUrl, options);

      if (statResponse.getResponseCode() === 200) {

        var statJson = JSON.parse(statResponse.getContentText());

        var stats = statJson.final_stat;

        var combatPower = stats.find(stat => stat.stat_name === "전투력").stat_value;

        sheet.getRange(6, 4 + i).setValue(Math.floor(combatPower / 10000)); // 전투력을 기록

      } else {

        Logger.log("전투력 API 응답 에러: " + statResponse.getContentText());

      }

    } catch (error) {

      Logger.log("전투력 API 호출 실패: " + error.toString());

    }

  }

}



/** Get Level */

function fetchCharacterLevels() {

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

  var range = sheet.getRange("D2:BZ2");

  var characters = range.getValues()[0];


  for (var i = 0; i < characters.length; i++) {

    var characterName = characters[i];

    if (characterName === "") continue;


    var ocid = fetchCharacterID(characterName);

    if (!ocid) {

      sheet.getRange(7, 4 + i).setValue("ocid 가져오기 실패");

      continue;

    }


    var basicUrl = "https://open.api.nexon.com/maplestory/v1/character/basic?ocid="; + encodeURIComponent(ocid);

    var options = {

      "method": "get",

      "headers": {

        "x-nxopen-api-key": apiKey,

        "accept": "application/json"

      },

      "muteHttpExceptions": true

    };


    try {

      var basicResponse = UrlFetchApp.fetch(basicUrl, options);

      if (basicResponse.getResponseCode() === 200) {

        var basicJson = JSON.parse(basicResponse.getContentText());

        var level = basicJson.character_level;

        sheet.getRange(7, 4 + i).setValue(level); // 레벨 기록

      } else {

        Logger.log("레벨 API 응답 에러: " + basicResponse.getContentText());

      }

    } catch (error) {

      Logger.log("레벨 API 호출 실패: " + error.toString());

    }

  }

}