Pycurl 403禁止访问融合页面时出现错误

时间:2018-09-16 02:41:37

标签: python pycurl

我正在设法使特定空间的内容汇合在一起。这需要我登录到另一个链接。

#!/usr/bin/python 
import pycurl, json 
from io import BytesIO 
import fileinput, os, re 
from urllib import urlencode 

URL = "..../wiki/rest/api/content/...." 
LOGIN_URL = ".../login" 


data = BytesIO() 
c = pycurl.Curl() 
c.setopt(pycurl.HTTPHEADER, ['Content-Type: application/json' ]) 
c.setopt(pycurl.USERPWD, "username:password") 

c.setopt(pycurl.COOKIEJAR, '/tmp/cookie.txt') 
c.setopt(pycurl.VERBOSE, True) 
c.setopt(pycurl.WRITEFUNCTION, data.write) 
c.setopt(pycurl.URL, LOGIN_URL) 
c.perform() 

c.setopt(pycurl.URL, URL) 
c.setopt(pycurl.COOKIEFILE, '/tmp/cookie.txt') 
c.setopt(pycurl.CUSTOMREQUEST, "GET") 

c.setopt(pycurl.WRITEFUNCTION, data.write) 
c.perform() 
print data.getvalue() 

但是我遇到了以下错误

{"statusCode":403,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"Not permitted to use confluence : null"}

当我粘贴URL而不登录时,我在Firefox中遇到了同样的错误。登录后粘贴URL时,没有任何问题,并且可以检索页面。

我能够成功存储cookie文件。 我应该添加些什么才能使其正常工作?

0 个答案:

没有答案