我在pythonanywhere
上使用python3.6
,当我尝试运行pydrive(自动将文件上载到google drive)时,我收到以下错误:-
You've reached this page because we have detected that Javascript is disabled in your browser. The page you attempted to load cannot display properly if scripts are disabled.
Please enable scripts and retry the operation or go back in your browser.
它要求我登录我的gmail帐户,所以我认为这就是问题所在,我如何解决这个问题
这是我的全部代码
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
def uploadimg(kart, band, fraction):
gauth = GoogleAuth()
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
gauth.Refresh()
else:
gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("mycreds.txt")
drive = GoogleDrive(gauth)
######################
file1 = drive.CreateFile({'title': "lqi"+fraction+"bandi"+band+"karti"+kart})
file1.SetContentFile("hi.jpg")
file1.Upload()
file3 = drive.CreateFile({'id': file1['id']})
uploadimg("h","h","e")
我不得不在远程服务器上使用
gauth.CommandLineAuth()
而不是gauth.LocalWebserverAuth()
相关问题 更多 >
编程相关推荐