Python module: requests

2013/12/03 Python

sslerror

behavior: requests.exceptions.SSLError:[Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

solutions:

  1. requests.get(‘https://somehost.com’, verify=False), ref: Python Requests throwing up SSLError
  2. use browser’s ca file, ref: How to find the path to a SSL cert file

disable logging

import logging
requests_log = logging.getLogger("requests")
requests_log.setLevel(logging.WARNING)

here we directly modify the requests logging level, which is not so simple. ref: How do I disable log messages from the Requests library?

disable redirect

if the page set redirect, requests will auto get the new location, which may not be what you expected, you can simply set allow_redirects=False to disable it.

License: (CC 3.0) BY-NC-SA

Search

    Table of Contents