【发布时间】:2013-06-12 20:44:05
【问题描述】:
class Crawl(webapp2.RequestHandler):
def get(self):
from google.appengine.api import urlfetch
url = "http://www.example.com/path/to a/page" #URL with a space
result = urlfetch.fetch(url)
self.response.write('url: %s' % (result.status_code)) ## Outputs 400
self.response.write(content) # Gives me 400 error page
我们不能否认有数以千计的 URL 包含空格这一事实。我们无法一一纠正。
为什么 urlfetch 对于这种可以通过浏览器完全访问的 URL 得到 400 bad request 错误?如何克服?
【问题讨论】:
-
我接受除了escape the request path in the url之外别无他法。谢谢大家帮助我。
标签: python google-app-engine url urlfetch http-status-code-400