使用facebook graph api,报错如下

一开始以为是https证书验证失败,查了一下午源码,没有看到问题,于是把Python27\lib\site-packages\requests\adapters.py文件的如下位置异常处理注释掉了,看看异常到底从哪来的

    def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
"""Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request content.
:param timeout: (optional) How long to wait for the server to send
data before giving up, as a float, or a :ref:`(connect timeout,
read timeout) <timeouts>` tuple.
:type timeout: float or tuple or urllib3 Timeout object
:param verify: (optional) Either a boolean, in which case it controls whether
we verify the server's TLS certificate, or a string, in which case it
must be a path to a CA bundle to use
:param cert: (optional) Any user-provided SSL certificate to be trusted.
:param proxies: (optional) The proxies dictionary to apply to the request.
:rtype: requests.Response
""" conn = self.get_connection(request.url, proxies) self.cert_verify(conn, request.url, verify, cert)
url = self.request_url(request, proxies)
self.add_headers(request) chunked = not (request.body is None or 'Content-Length' in request.headers) if isinstance(timeout, tuple):
try:
connect, read = timeout
timeout = TimeoutSauce(connect=connect, read=read)
except ValueError as e:
# this may raise a string formatting error.
err = ("Invalid timeout {0}. Pass a (connect, read) "
"timeout tuple, or a single float to set "
"both timeouts to the same value".format(timeout))
raise ValueError(err)
elif isinstance(timeout, TimeoutSauce):
pass
else:
timeout = TimeoutSauce(connect=timeout, read=timeout) try:
if not chunked:
resp = conn.urlopen(
method=request.method,
url=url,
body=request.body,
headers=request.headers,
redirect=False,
assert_same_host=False,
preload_content=False,
decode_content=False,
retries=self.max_retries,
timeout=timeout
) # Send the request.
else:
if hasattr(conn, 'proxy_pool'):
conn = conn.proxy_pool low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT) try:
low_conn.putrequest(request.method,
url,
skip_accept_encoding=True) for header, value in request.headers.items():
low_conn.putheader(header, value) low_conn.endheaders() for i in request.body:
low_conn.send(hex(len(i))[2:].encode('utf-8'))
low_conn.send(b'\r\n')
low_conn.send(i)
low_conn.send(b'\r\n')
low_conn.send(b'0\r\n\r\n') # Receive the response from the server
try:
# For Python 2.7+ versions, use buffering of HTTP
# responses
r = low_conn.getresponse(buffering=True)
except TypeError:
# For compatibility with Python 2.6 versions and back
r = low_conn.getresponse() resp = HTTPResponse.from_httplib(
r,
pool=conn,
connection=low_conn,
preload_content=False,
decode_content=False
)
except:
# If we hit any problems here, clean up the connection.
# Then, reraise so that we can handle the actual exception.
low_conn.close()
raise except (ProtocolError, socket.error) as err:
raise ConnectionError(err, request=request) except MaxRetryError as e:
if isinstance(e.reason, ConnectTimeoutError):
# TODO: Remove this in 3.0.0: see #2811
if not isinstance(e.reason, NewConnectionError):
raise ConnectTimeout(e, request=request) if isinstance(e.reason, ResponseError):
raise RetryError(e, request=request) if isinstance(e.reason, _ProxyError):
raise ProxyError(e, request=request) raise ConnectionError(e, request=request) except ClosedPoolError as e:
raise ConnectionError(e, request=request) except _ProxyError as e:
raise ProxyError(e) # except (_SSLError, _HTTPError) as e:
# if isinstance(e, _SSLError):
# raise SSLError(e, request=request)
# elif isinstance(e, ReadTimeoutError):
# raise ReadTimeout(e, request=request)
# else:
# raise return self.build_response(request, resp)

注释后报错

于是把Python27\lib\site-packages\urllib3\connectionpool.py625到630行注释掉

报错

最后估计是proxy的问题,找了一个墙外的服务器试一下果然好了,不翻墙就办不成事,shit

祝病魔早日战胜方校长

facebook graph api 报错SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)')的更多相关文章

  1. 【Python】【BugList13】req = requests.get(url=target)报错: (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)')

    [代码] # -*- coding:UTF-8 -*- import requests if __name__ == '__main__': target = 'https://unsplash.co ...

  2. ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)

    /******************************************************************************* * ssl.SSLError: [SS ...

  3. keras 下载预训练模型报错SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

    import ssl ssl._create_default_https_context = ssl._create_unverified_context https://stackoverflow. ...

  4. requests https访问错误SSLError: certificate verify failed 及InsecureRequestWarning处理办法

    转自: https://blog.csdn.net/mighty13/article/details/78076258?locationNum=3&fps=1 在使用requests访问某网站 ...

  5. Python常见问题 - python3 使用requests发送HTTPS请求报certificate verify failed 错误

    当你使用 requests 发送HTTPS请求时 requests.get(url, parmas=parmas, headers=header, cookies=cookie) 出现了以下错误 HT ...

  6. open-falcon ---安装Dashboard时候报错"SSLError: The read operation timed out"

    在部署open-falcon环境过程中,安装Dashboard时候报错"SSLError: The read operation timed out".如下: [root@open ...

  7. 在PHP5.4上使用Google翻译的API报错

    /********************************************************************** * 在PHP5.4上使用Google翻译的API报错 * ...

  8. python2.7运行selenium webdriver api报错Unable to find a matching set of capabilities

    在火狐浏览器33版本,python2.7运行selenium webdriver api报错:SessionNotCreatedException: Message: Unable to find a ...

  9. 使用IDEA操作Hbase API 报错:org.apache.hadoop.hbase.client.RetriesExhaustedException的解决方法:

     使用IDEA操作Hbase API 报错:org.apache.hadoop.hbase.client.RetriesExhaustedException的解决方法: 1.错误详情: Excepti ...

随机推荐

  1. eclipse不能自动编译XX.java为XX.classs

    问题描述:eclipse不能自动编译XX.java为XX.classs 原因:今天下午写代码,因为需要引入jstl包,引入后发现原来项目中已经引入了,然后我又把包删除了,忘记删除java build ...

  2. Android中开发习惯

    我觉得首先是命名规范.命名规范这种东西每个人都有自己的风格,Google 也有自己的一套规范(多看看 Android 系统源码就明白了).好的规范可以有效地提高代码的可读性,对于将来接手代码的小伙伴也 ...

  3. js获取一个字符串中指定字符第n次出现的位置

    function nthIndexOf(str,c,n){ var x=str.indexOf(c); for(var i=0;i<num;i++){ x=str.indexOf(c,x+1); ...

  4. 控制input框的内容输入为数字

    <script> function toNum(v) { return v.replace(/[^\d.]/g, '').replace(/^\./g, "").rep ...

  5. shell中特殊变量$0 $1 $# $$ $! $?的涵义

    $0: 执行脚本的名字 $*和$@: 将所有参数返回 $#: 参数的个数 $_: 代表上一个命令的最后一个参数 $$: 代表所在命令的PID $!: 代表最后执行的后台命令的PID $?: 代表上一个 ...

  6. 【BZOJ3529】[Sdoi2014]数表 莫比乌斯反演+树状数组

    [BZOJ3529][Sdoi2014]数表 Description 有一张N×m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和 ...

  7. Unity3D笔记九 发送广播与消息、利用脚本控制游戏

    一.发送广播与消息 游戏对象之间发送的广播与消息分为三种:第一种向子对象发送,将发送至该对象的同辈对象或者子孙对象中:第二种为给自己发送,发送至自己本身对象:第三种为向父对象发送,发送至该对象的同辈或 ...

  8. R向量匹配match和pmatch

    match(x, table, nomatch = NA_integer_, incomparables = NULL) x: 向量, 要匹配的值; table: 向量, 被匹配的值; nomatch ...

  9. Win7系统右上角没有搜索怎么办?Win7找回资源管理器中的搜索框

    最近有win7系统用户发现打开资源管理器,文件夹等右上角没有搜索框,这让人十分不方便无法进行搜索,那么如何找回呢?下面小编就分享一下方法给大家.推荐 最好用的Win7系统下载 操作步骤: 1.打开Wi ...

  10. php 判断变量函数

    1.isset功能:判断变量是否被初始化 判断变量是否被定义了 2.empty功能:检测变量是否为"空" 说明:任何一个未初始化的变量.值为 0 或 false 或 空字符串&qu ...