import requests
def worksh(code,num):
web="https://spreadsheets.google.com/feeds/worksheets/"+code+"/public/basic"
r = requests.get(web)
m=r.text
xx=m.split("</entry>")
str=xx[num]
p1=str.index("<entry>")
str=str[p1:]
p1=str.index("<id>")
p2=str.index("</id>")
str=str[p1:p2]
p1=str.index("/basic/")
z=str[p1:]
ws=z.replace("/basic/","")
return ws
def catchdata(code,ws):
web="https://spreadsheets.google.com/feeds/cells/"+code+"/"+ws+"/public/values"
r = requests.get(web)
m=r.text
de=m.split("</gs:cell")
for i in range(len(de)):
q1=de[i].find("<gs:cell")
de[i]=de[i][q1:]
for i in range(len(de)-1):
r1=de[i].find("row=")
r2=de[i].find("'",r1+5)
r=de[i][r1+5:r2]
c1=de[i].find("col=")
c2=de[i].find("'",c1+5)
c=de[i][c1+5:c2]
v1=de[i].find(">")
vv=de[i][v1+1:]
y.append(int(r))
x.append(int(c))
v.append(vv)
lastrow=1
for i in range(len(y)):
if y[i] > lastrow:
lastrow=y[i]
lastcol=1
for i in range(len(x)):
if x[i] > lastcol:
lastcol=x[i]
code="1uzhQYfrOMsY0C-svvEGDZpF8tHVpo0be9NIpY1p_p-E"
ws=worksh(code,0)
y=[]
x=[]
v=[]
catchdata(code,ws)
print(v)
最終更新:2018年01月12日 11:32