Google Apps 스크립트는 반환에서 원하는 결과를 실행 로그하지만,셀룰라 스프레드시트에서는 빈

0

질문

에서 이러 스프레드시트,응용 프로그램 스크립트를 반환합니다 오른쪽 결과를 때 나는 그것을 실행 실행 로그가 올바르게 반환"202000.0".

그러나,스크립트를 실행할 때에 셀(에서 강조된 오렌지에 연결된 스프레드시트),셀,빈 사람이 어떻게 개선할 수 있는지 알고 있어요?

앱 스크립트 코드:

function fullTimeEmployees(url) {
  var url = 'https://finance.yahoo.com/quote/WBA/profile'
  var source = UrlFetchApp.fetch(url).getContentText()
  var jsonString = source.match(/root.App.main = ([\s\S\w]+?);\n/)
  if (!jsonString || jsonString.length == 1) return;
  var data = JSON.parse(jsonString[1].trim())
  Logger.log(data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees)
}

또한,사람을 알고 내가 무엇을 변경할 수 있습니다.fulltimeEmployees(끝)에서 반환하는 전체 회사 이름? 으로 여기 사진,녹색으로 강조 표시 company name section

1

최고의 응답

1

질문에 대한 답 1:

그러나,스크립트를 실행할 때에 셀(에서 강조된 오렌지에 연결된 스프레드시트),셀,빈 사람이 어떻게 개선할 수 있는지 알고 있어요?

스크립트에서는 아무 값이 반환됩니다. 이것은 이유는 당신의 문제입니다. 그래서를 수정하십시오 스크립트는 다음과 같습니다.

function fullTimeEmployees(url) {
  var url = 'https://finance.yahoo.com/quote/WBA/profile'
  var source = UrlFetchApp.fetch(url).getContentText()
  var jsonString = source.match(/root.App.main = ([\s\S\w]+?);\n/)
  if (!jsonString || jsonString.length == 1) return;
  var data = JSON.parse(jsonString[1].trim())
  Logger.log(data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees)
  return data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees; // Added
}

질문에 대한 답 2:

또한,사람을 알고 내가 무엇을 변경할 수 있습니다.fulltimeEmployees(끝)에서 반환하는 전체 회사 이름? 으로 여기 사진,녹색으로 강조 표시

이 경우에는 방법에 대한 수정은 다음과 같?

From:

data.context.dispatcher.stores.QuoteSummaryStore.assetProfile.fullTimeEmployees

하기:

data.context.dispatcher.stores.QuoteSummaryStore.price.shortName
  • 의 값이 Walgreens Boots Alliance, Inc..
2021-11-23 23:59:44

당신이 절대적인 스타!! 내가 진정으로 감사를 드려야 할지 모르겠습니다.으로,초보자 코딩을 가진 나는 수많은 시간 보내려고 이를 달성하기 위해 최종 목표 그래서 정말 감사에서 당신의 도움에 마지막으로 받고 있다.
DarkWingDuck

@DarkWingDuck 감사에 대한 회신하고 테스트하였습니다. 난 당신의 문제가 해결되었습니다. 감사합니다.
Tanaike

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................