我有一个.py文件,该文件使用sheet.find(“ words”)方法/函数。它已经(100%)工作了几周(每天运行10次代码),但是它在2019年7月14日0200Z左右开始引发503错误(如下)。
我还有另一个.py脚本,该脚本也执行类似的任务,并且现在可以完美地使用sheet.find(“ words”)方法/函数。这是完整的错误
Traceback (most recent call last):
File "D:\....file_path_for_file2\file2.py", line 58, in <module>
hi=sheet.find("it's down there somewhere, let me take another look.")
File "C:\....file_path_for_gspread\gspread\models.py", line 997, in find
return self._finder(finditem, query)
File "C:\....file_path_for_gspread\gspread\models.py", line 969, in _finder
data = self.spreadsheet.values_get(self.title)
File "C:....file_path_for_gspread\gspread\models.py", line 148, in values_get
r = self.client.request('get', url, params=params)
File "C:\....file_path_for_gspread\gspread\client.py", line 79, in request
raise APIError(response)
gspread.exceptions.APIError: {
"error": {
"code": 503,
"message": "The service is currently unavailable.",
"status": "UNAVAILABLE"
}
}
这是我所知道的:
sheet.update_acell('e3', "it's down there somewhere, let me take another look.")
以上方法在100%的时间内都有效,并将单词粘贴到单元格E3中。
故障.py文件已被简化为仅用于测试(请参见下面的代码)
另一个.py文件可以运行sheet.find的70次迭代,并且可以完美地工作(但是,它是在不同于文件2.py的其他Google表格和其他计算机文件夹中进行编辑/查找)
在Windows 10和Python 3.7.0上运行(v3.7.0:1bf9cc5093,Jun 27 2018,04:06:47)
这是目前的完整代码:
import gspread
#documentation https://gspread.readthedocs.io/en/latest/api.html
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open("stks_rl").worksheet("spxl")
sheet.update_acell('e3', "it's down there somewhere, let me take another look.")
hi=sheet.find("it's down there somewhere, let me take another look.")
print(hi)
预期结果是:
<Cell R3C5 "it's down there somewhere, let me take another look.">
实际结果是:
gspread.exceptions.APIError: {
"error": {
"code": 503,
"message": "The service is currently unavailable.",
"status": "UNAVAILABLE"