简体   繁体   中英

Convert requests code to urllib in python

I'm using requests module in my app but when i run it in google app engine, raise SSL Connection exception:

File "/base/data/home/apps/s~myapp/1.385939809966824449/lib/requests/adapters.py", line 429, in send
    raise SSLError(e, request=request)
SSLError: Can't connect to HTTPS URL because the SSL module is not available.

I google this problem and read some answers that said SSL module is not in GAE while list . I can send a simple GET request with urllib . It was ok. What is equivalent of requests.request('GET', request_url, params=params, files=files) in urllib ?

I use this:

import urllib
import urllib2
result = urllib2.urlopen(request_url, urllib.urlencode(params))
if result.getcode() == 200:
    pass #change it

but this code just can send text and numbers not files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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