Google 드라이브 시트를 사용하여 간단한 데이터 저장소로 사용하고 있습니다. Google은 클라이언트 사이드 스크립트 호출 브라우저을 통해 공개 시트에서 피드를 얻는 것이 매우 편리합니다.클라이언트 측 스크립트 호출을 서버로 이동하려면 어떻게합니까? (Google 드라이브 스프레드 시트 피드)
<script type="text/javascript">
function useJSONdata(root) {
var feed = root.feed;
var entries = feed.entry || [];
var html = [''];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
(process the data, etc...)
}
}
</script>
<body>
<script src='https://spreadsheets.google.com/feeds/list/xxxxxxxxxxxxxxxx/od6/public/full?alt=json-in-script&callback=useJSONdata'></script>
</body>
이 기술에는 많은 정보가 있습니다. Old technique here 및 here. handy flash card tool I wrote에 대한 링크가 있습니다. 코드는 모두 브라우저의 개발 도구에 표시됩니다.
현재 사용중인 경우 서버에있는 node.js의 Google 스프레드 시트 데이터에 액세스하고 싶습니다. 유효한 클라이언트 코드에서 <script src='https://...&callback=...'></script>
이라는 최상의 번역본을 볼 수 없습니다.
저는 GET과 POST 모두 https 요청을 사용하여이 작업을 시도하고 있습니다. 나는 그 요청이 데이터를 얻고 있음을 알 수 있지만, 반환 된 데이터는 어지러운 것이다. 나는 내용의 10 라인과 스프레드 시트에 반환 된 정보의 7000 라인을 찾고 있어요. 내 노드에서 반환 된 데이터를 찾고 있었어요
encoding:"UTF-8"
feed:
author:[{…}]
category:[{…}]
entry:(167) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, …]
id:{$t: "https://spreadsheets.google.com/feeds/list/xxxxxxxx/od6/public/full"}
link:(4) [{…}, {…}, {…}, {…}]
openSearch$startIndex:{$t: "1"}
openSearch$totalResults:{$t: "167"}
title:{type: "text", $t: "Sheet1"}
updated:{$t: "2015-04-04T19:31:32.089Z"}
xmlns:"http://www.w3.org/2005/Atom"
xmlns$gsx:"http://schemas.google.com/spreadsheets/2006/extended"
xmlns$openSearch:"http://a9.com/-/spec/opensearchrss/1.0/"
__proto__:Object
: curl https://spreadsheets.google.com/feeds/list/1s9-AyqYqp25s2OeGiglCSNF2UcvJJm50Ipvm8v0Mgo0/od6/public/full?alt=json-in-script
데이터 브라우저에서 <script src=...
요청을 반환 : 여기
response: IncomingMessage
client:TLSSocket {_tlsOptions: {…}, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, …}
complete:false
connection:TLSSocket {_tlsOptions: {…}, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, …}
domain:null
headers:{content-type: "application/atom+xml; charset=UTF-8", x-robots-tag: "noindex, nofollow, nosnippet", expires: "Wed, 27 Dec 2017 02:50:15 GMT", date: "Wed, 27 Dec 2017 02:50:15 GMT", cache-control: "private, max-age=0, must-revalidate, no-transform", …}
httpVersion:"1.1"
httpVersionMajor:1
httpVersionMinor:1
method:null
rawHeaders:(38) ["Content-Type", "application/atom+xml; charset=UTF-8", "X-Robots-Tag", "noindex, nofollow, nosnippet", "Expires", "Wed, 27 Dec 2017 02:50:15 GMT", "Date", "Wed, 27 Dec 2017 02:50:15 GMT", "Cache-Control", "private, max-age=0, must-revalidate, no-transform", "Vary", "Accept, X-GData-Authorization, GData-Version", "GData-Version", "1.0", "Last-Modified", "Tue, 26 Dec 2017 20:36:41 GMT", "Transfer-Encoding", "chunked", "P3P", "CP="This is not a P3P policy! See g.co/p3phelp for more info."", "P3P", "CP="This is not a P3P policy! See g.co/p3phelp for more info."", "X-Content-Type-Options", "nosniff", "X-Frame-Options", "SAMEORIGIN", "X-XSS-Protection", "1; mode=block", "Server", "GSE", "Set-Cookie", "NID=120=CFx_iglHazKNNR7tH33m4UkGABss7TV9bB03EVnZrH…=/;Expires=Thu, 28-Jun-2018 02:50:15 GMT;HttpOnly", "Set-Cookie", "NID=120=W3n0zQ1UWJz6pmTOjKjAxuMtG5WOLx2D3OiQca5R9A…=/;Expires=Thu, 28-Jun-2018 02:50:15 GMT;HttpOnly", "Alt-Svc", "hq=":443"; ma=2592000; quic=51303431; quic=5130333…03335,quic=":443"; ma=2592000; v="41,39,38,37,35"", "Connection", "close"]
rawTrailers:[]
read:ƒ (n)
readable:true
req:ClientRequest {domain: null, _events: {…}, _eventsCount: 2, _maxListeners: undefined, output: Array(0), …}
socket:TLSSocket {_tlsOptions: {…}, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, …}
statusCode:200
statusMessage:"OK"
trailers:{}
upgrade:false
url:""
_consuming:true
_dumped:false
_events:{end: ƒ, data: ƒ}
_eventsCount:2
_maxListeners:undefined
_readableState:ReadableState {objectMode: false, highWaterMark: 16384, buffer: BufferList, length: 0, pipes: null, …}
destroyed:(...)
readableHighWaterMark:(...)
__proto__:Readable
는 Google 드라이브 스프레드 시트의 데이터에 대한 서버 요청에 그
<script src=...
코드를 변환하는 더 좋은 방법이 있나요? 여기에 온 사람 있니?
Google 스프레드 시트를 볼 수있는 전체 node.js 라이브러리는 다음과 같습니다. https://developers.google.com/sheets/api/quickstart/nodejs –
@ChrisRiebschlager 분명히 올바른 방법이 가장 좋습니다. 앞으로. 새로운 Google 스프레드 시트 API (ver 4)는 이전 단순 피드에 필요하지 않은 OAuth 권한을 사용합니다. 앞으로는 새로운 프로젝트를 위해 활용 하겠지만 이전 API 버전 피드에 대한 내 자신의 질문에 대답하려고합니다. 링크에 대한 THX. – zipzit