我一直在試圖學習Python這幾天,我遇到了一個問題,我不太清楚如何解決。我正在嘗試製作一個簡單的reddit機器人並學習praw reddit API。當我運行下面的機器人:SSL認證驗證失敗
import praw
import time
r = praw.Reddit('testmachine11968986531')
test = r.submission(id="5u7q8x")
comment_user = set() # to avoid duplicates
for i in xrange(0,10): # Run the loop 10 times
#comments = r.comments(submission)
for comment in test.comments:
body = comment.body.lower()
if body.find("think") != -1 or body.find("please") != -1:
comment_user.add(comment.author)
#time.sleep(120) # Sleep for 2 minutes
print "Here are some comments:"
for user in polite_users:
print user
我得到一個錯誤:
RequestException: error with request [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
我周圍戳,看到我可以在一個get插入類似
verify = False
()類的實例,但我不確定這是否會在這個特定的例子中起作用。一切工作正常我相信 - 我可以使用PIP就好了,等等。
任何幫助,將不勝感激。萬分感謝。
編輯:完整的錯誤回溯是
Traceback (most recent call last):
File "C:\Users\**\Desktop\Bottest\startBot.py", line 16, in <module>
for comment in test.comments:
File "C:\Python27\lib\site-packages\praw\models\reddit\base.py", line 31, in __getattr__
self._fetch()
File "C:\Python27\lib\site-packages\praw\models\reddit\submission.py", line 133, in _fetch
'sort': self.comment_sort})
File "C:\Python27\lib\site-packages\praw\reddit.py", line 320, in get
data = self.request('GET', path, params=params)
File "C:\Python27\lib\site-packages\praw\reddit.py", line 404, in request
params=params)
File "C:\Python27\lib\site-packages\prawcore\sessions.py", line 133, in request
self._authorizer.refresh()
File "C:\Python27\lib\site-packages\prawcore\auth.py", line 328, in refresh
password=self._password)
File "C:\Python27\lib\site-packages\prawcore\auth.py", line 138, in _request_token
response = self._authenticator._post(url, **data)
File "C:\Python27\lib\site-packages\prawcore\auth.py", line 29, in _post
data=sorted(data.items()))
File "C:\Python27\lib\site-packages\prawcore\requestor.py", line 48, in request
raise RequestException(exc, args, kwargs)
RequestException: error with request [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
你在哪裏得到錯誤? –
@ claymore-adrendamar我繼續編輯它在身體 – AON
這可能是有幫助的。但不知道。 http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error – Marviel