Python 谷歌应用引擎:HTTP错误403:禁止

Python 谷歌应用引擎:HTTP错误403:禁止,python,google-app-engine,google-api,Python,Google App Engine,Google Api,我正在使用GoogleBooksAPI与我正在开发的一个电子商务网站进行集成。其想法是让用户使用搜索栏搜索图书,然后调用GoogleAPI输出与搜索关键字对应的图书数量 但是,在表单中输入查询后,单击submit后,我得到一个403禁止错误。这很奇怪,因为我在本地主机上测试应用程序时从未发生过这种情况。以下是我的应用程序代码: main.py class SearchHandler(Handler): def get(self): self.render("search.

我正在使用GoogleBooksAPI与我正在开发的一个电子商务网站进行集成。其想法是让用户使用搜索栏搜索图书,然后调用GoogleAPI输出与搜索关键字对应的图书数量

但是,在表单中输入查询后,单击submit后,我得到一个403禁止错误。这很奇怪,因为我在本地主机上测试应用程序时从未发生过这种情况。以下是我的应用程序代码:

main.py

class SearchHandler(Handler):
    def get(self):
        self.render("search.html")
    def post(self):
        keey = self.request.get('keey')
        finaal = "https://www.googleapis.com/books/v1/volumes?q=" + keey + "&key=MY_APP_KEY"
        f = urllib2.urlopen(finaal).read()
        self.render("jsony.html", finaal = finaal)

app = webapp2.WSGIApplication(('/search', SearchHandler)], debug=True)
search.html

<html>
<head>
    <title>Web Mining</title>
</head>
<body>
    <form method = "post">
        Book Name:<input type = "text" name = "keey">
        <input type = "submit">
    </form>
</body>
</html> 

然而,为了从源代码中提取数据,我需要API的URL。发生了什么事?

尝试将
&country=US
添加到URL查询字符串。

是否转到
https://console.developers.google.com/project/apps~YOUR-APP/apui/api
打开图书api?是的,我打开了。但是,同样的错误。作为一个单独的问题,您从未使用
f=…
。您只是将
final
字符串发送到模板。你确定你有正确的
键吗?尝试在浏览器中直接访问该url。是的,我可以通过直接访问浏览器上的链接来访问JSON格式。Google Books API似乎禁止我在向他们发送请求时访问他们的页面。在您尝试打开页面之前,请确保它是您所认为的
<html>
<head>
    <title>Web Mining</title>
</head>
<body>
    <form method = "post">
        {{finaal}}
    </form>
</body>
f = urllib2.urlopen(finaal).read()