简体   繁体   English

如何修复请求(urllib3)与app引擎一起工作?

[英]How to fix requests (urllib3) work with app engine?

I use requests library (or urllib3), trying to get xml page from web site. 我使用请求库(或urllib3),试图从网站获取xml页面。 And my code is working, but when i use it in app engine it shows an error 我的代码工作正常,但是当我在app引擎中使用它时会显示错误

    Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\main.py", line 51, in get
    class_list = get_class_list()
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\get_class_urllib3.py", line 6, in get_class_list
    r = http.request('POST', 'http://sgo.volganet.ru/lacc.asp?Function=GetClassListForSchool&SchoolID=1460')
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\request.py", line 73, in request
    **urlopen_kw)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\request.py", line 151, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\poolmanager.py", line 165, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\connectionpool.py", line 558, in urlopen
    body=body, headers=headers)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\connectionpool.py", line 389, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\util\response.py", line 49, in assert_header_parsing
    type(headers)))

TypeError: expected httplib.Message, got <type 'instance'>.

So can you help me to fix this problem or suggest any module I can use in app angine to create post request to differen site. 那么你可以帮助我解决这个问题或建议我可以在app angine中使用的任何模块来创建对不同站点的发布请求。

我建议使用AppEngine提供的API: urlfetch.fetch()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM