本文整理汇总了Python中pycurl.VERBOSE属性的典型用法代码示例。如果您正苦于以下问题:Python pycurl.VERBOSE属性的具体用法?Python pycurl.VERBOSE怎么用?Python pycurl.VERBOSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pycurl
的用法示例。
在下文中一共展示了pycurl.VERBOSE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _curl_create
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def _curl_create(self):
curl = pycurl.Curl()
if curl_log.isEnabledFor(logging.DEBUG):
curl.setopt(pycurl.VERBOSE, 1)
curl.setopt(pycurl.DEBUGFUNCTION, self._curl_debug)
return curl
示例2: request
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def request(self, endpoint, headers=None, post=None, first=True):
buffer = BytesIO()
ch = pycurl.Curl()
ch.setopt(pycurl.URL, endpoint)
ch.setopt(pycurl.USERAGENT, self.userAgent)
ch.setopt(pycurl.WRITEFUNCTION, buffer.write)
ch.setopt(pycurl.FOLLOWLOCATION, True)
ch.setopt(pycurl.HEADER, True)
if headers:
ch.setopt(pycurl.HTTPHEADER, headers)
ch.setopt(pycurl.VERBOSE, self.debug)
ch.setopt(pycurl.SSL_VERIFYPEER, False)
ch.setopt(pycurl.SSL_VERIFYHOST, False)
ch.setopt(pycurl.COOKIEFILE, self.settingsPath + self.username + '-cookies.dat')
ch.setopt(pycurl.COOKIEJAR, self.settingsPath + self.username + '-cookies.dat')
if post:
import urllib
ch.setopt(pycurl.POST, len(post))
ch.setopt(pycurl.POSTFIELDS, urllib.urlencode(post))
ch.perform()
resp = buffer.getvalue()
header_len = ch.getinfo(pycurl.HEADER_SIZE)
header = resp[0: header_len]
body = resp[header_len:]
ch.close()
if self.debug:
import urllib
print("REQUEST: " + endpoint)
if post is not None:
if not isinstance(post, list):
print('DATA: ' + urllib.unquote_plus(json.dumps(post)))
print("RESPONSE: " + body + "\n")
return [header, json_decode(body)]
示例3: request
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def request(self, endpoint, post=None):
buffer = BytesIO()
ch = pycurl.Curl()
ch.setopt(pycurl.URL, Constants.API_URL + endpoint)
ch.setopt(pycurl.USERAGENT, self.userAgent)
ch.setopt(pycurl.WRITEFUNCTION, buffer.write)
ch.setopt(pycurl.FOLLOWLOCATION, True)
ch.setopt(pycurl.HEADER, True)
ch.setopt(pycurl.VERBOSE, False)
ch.setopt(pycurl.COOKIEFILE, os.path.join(self.IGDataPath, self.username, self.username + "-cookies.dat"))
ch.setopt(pycurl.COOKIEJAR, os.path.join(self.IGDataPath, self.username, self.username + "-cookies.dat"))
if post is not None:
ch.setopt(pycurl.POST, True)
ch.setopt(pycurl.POSTFIELDS, post)
if self.proxy:
ch.setopt(pycurl.PROXY, self.proxyHost)
if self.proxyAuth:
ch.setopt(pycurl.PROXYUSERPWD, self.proxyAuth)
ch.perform()
resp = buffer.getvalue()
header_len = ch.getinfo(pycurl.HEADER_SIZE)
header = resp[0: header_len]
body = resp[header_len:]
ch.close()
if self.debug:
print("REQUEST: " + endpoint)
if post is not None:
if not isinstance(post, list):
print("DATA: " + str(post))
print("RESPONSE: " + body)
return [header, json_decode(body)]
示例4: _curl_create
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def _curl_create():
curl = pycurl.Curl()
if gen_log.isEnabledFor(logging.DEBUG):
curl.setopt(pycurl.VERBOSE, 1)
curl.setopt(pycurl.DEBUGFUNCTION, _curl_debug)
return curl
示例5: _curl_create
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def _curl_create(max_simultaneous_connections=None):
curl = pycurl.Curl()
if logging.getLogger().isEnabledFor(logging.DEBUG):
curl.setopt(pycurl.VERBOSE, 1)
curl.setopt(pycurl.DEBUGFUNCTION, _curl_debug)
curl.setopt(pycurl.MAXCONNECTS, max_simultaneous_connections or 5)
return curl
示例6: set_debug
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def set_debug(self):
if self.debug:
self.curl.setopt(pycurl.VERBOSE, 1)
self.curl.setopt(pycurl.DEBUGFUNCTION, self.print_debug_info)
示例7: wrap_prepare_curl_callback
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def wrap_prepare_curl_callback(self, callback):
def _wrap_prepare_curl_callback(curl):
if self.debug:
curl.setopt(pycurl.VERBOSE, 1)
if callback:
return callback(curl)
return _wrap_prepare_curl_callback
示例8: set_verbosity
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def set_verbosity(self, level):
"Set verbosity to 1 to see transactions."
self.set_option(pycurl.VERBOSE, level)
示例9: _set_only_receive_headers
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def _set_only_receive_headers(self):
self._curl.setopt(pycurl.VERBOSE, True)
self._curl.setopt(pycurl.RANGE, "0-0")
self._curl.setopt(pycurl.HEADERFUNCTION, self._response_header_handler.response_header_handler)
self._curl.setopt(pycurl.WRITEDATA, None)
示例10: init_pycurl
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def init_pycurl(debug=False):
"""
Provides an instances of pycurl with basic configuration
:return: pycurl instance
"""
_curl = pycurl.Curl()
_curl.setopt(pycurl.SSL_OPTIONS, pycurl.SSLVERSION_TLSv1_2)
_curl.setopt(pycurl.SSL_VERIFYPEER, False)
_curl.setopt(pycurl.SSL_VERIFYHOST, False)
_curl.setopt(pycurl.VERBOSE, debug)
_curl.setopt(pycurl.TIMEOUT, 10)
_curl.setopt(pycurl.COOKIEFILE, "")
_curl.setopt(pycurl.USERAGENT, 'APIFuzzer')
return _curl
示例11: get
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def get(self,
url,
header=None,
proxy_host=None,
proxy_port=None,
cookie_file=None):
'''
open url width get method
@param url: the url to visit
@param header: the http header
@param proxy_host: the proxy host name
@param proxy_port: the proxy port
'''
crl = pycurl.Curl()
#crl.setopt(pycurl.VERBOSE,1)
crl.setopt(pycurl.NOSIGNAL, 1)
# set proxy
# crl.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
rel_proxy_host = proxy_host or self.proxy_host
if rel_proxy_host:
crl.setopt(pycurl.PROXY, rel_proxy_host)
rel_proxy_port = proxy_port or self.proxy_port
if rel_proxy_port:
crl.setopt(pycurl.PROXYPORT, rel_proxy_port)
# set cookie
rel_cookie_file = cookie_file or self.cookie_file
if rel_cookie_file:
crl.setopt(pycurl.COOKIEFILE, rel_cookie_file)
crl.setopt(pycurl.COOKIEJAR, rel_cookie_file)
# set ssl
crl.setopt(pycurl.SSL_VERIFYPEER, 0)
crl.setopt(pycurl.SSL_VERIFYHOST, 0)
crl.setopt(pycurl.SSLVERSION, 3)
crl.setopt(pycurl.CONNECTTIMEOUT, 10)
crl.setopt(pycurl.TIMEOUT, 300)
crl.setopt(pycurl.HTTPPROXYTUNNEL, 1)
rel_header = header or self.header
if rel_header:
crl.setopt(pycurl.HTTPHEADER, rel_header)
crl.fp = StringIO.StringIO()
if isinstance(url, unicode):
url = str(url)
crl.setopt(pycurl.URL, url)
crl.setopt(crl.WRITEFUNCTION, crl.fp.write)
try:
crl.perform()
except Exception, e:
raise CurlException(e)
示例12: post
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def post(self,
url,
data,
header=None,
proxy_host=None,
proxy_port=None,
cookie_file=None):
'''
open url width post method
@param url: the url to visit
@param data: the data to post
@param header: the http header
@param proxy_host: the proxy host name
@param proxy_port: the proxy port
'''
crl = pycurl.Curl()
#crl.setopt(pycurl.VERBOSE,1)
crl.setopt(pycurl.NOSIGNAL, 1)
# set proxy
rel_proxy_host = proxy_host or self.proxy_host
if rel_proxy_host:
crl.setopt(pycurl.PROXY, rel_proxy_host)
rel_proxy_port = proxy_port or self.proxy_port
if rel_proxy_port:
crl.setopt(pycurl.PROXYPORT, rel_proxy_port)
# set cookie
rel_cookie_file = cookie_file or self.cookie_file
if rel_cookie_file:
crl.setopt(pycurl.COOKIEFILE, rel_cookie_file)
crl.setopt(pycurl.COOKIEJAR, rel_cookie_file)
# set ssl
crl.setopt(pycurl.SSL_VERIFYPEER, 0)
crl.setopt(pycurl.SSL_VERIFYHOST, 0)
crl.setopt(pycurl.SSLVERSION, 3)
crl.setopt(pycurl.CONNECTTIMEOUT, 10)
crl.setopt(pycurl.TIMEOUT, 300)
crl.setopt(pycurl.HTTPPROXYTUNNEL, 1)
rel_header = header or self.header
if rel_header:
crl.setopt(pycurl.HTTPHEADER, rel_header)
crl.fp = StringIO.StringIO()
crl.setopt(crl.POSTFIELDS, data) # post data
if isinstance(url, unicode):
url = str(url)
crl.setopt(pycurl.URL, url)
crl.setopt(crl.WRITEFUNCTION, crl.fp.write)
try:
crl.perform()
except Exception, e:
raise CurlException(e)
示例13: upload
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def upload(self,
url,
data,
header=None,
proxy_host=None,
proxy_port=None,
cookie_file=None):
'''
open url with upload
@param url: the url to visit
@param data: the data to upload
@param header: the http header
@param proxy_host: the proxy host name
@param proxy_port: the proxy port
'''
crl = pycurl.Curl()
#crl.setopt(pycurl.VERBOSE,1)
crl.setopt(pycurl.NOSIGNAL, 1)
# set proxy
rel_proxy_host = proxy_host or self.proxy_host
if rel_proxy_host:
crl.setopt(pycurl.PROXY, rel_proxy_host)
rel_proxy_port = proxy_port or self.proxy_port
if rel_proxy_port:
crl.setopt(pycurl.PROXYPORT, rel_proxy_port)
# set cookie
rel_cookie_file = cookie_file or self.cookie_file
if rel_cookie_file:
crl.setopt(pycurl.COOKIEFILE, rel_cookie_file)
crl.setopt(pycurl.COOKIEJAR, rel_cookie_file)
# set ssl
crl.setopt(pycurl.SSL_VERIFYPEER, 0)
crl.setopt(pycurl.SSL_VERIFYHOST, 0)
crl.setopt(pycurl.SSLVERSION, 3)
crl.setopt(pycurl.CONNECTTIMEOUT, 10)
crl.setopt(pycurl.TIMEOUT, 300)
crl.setopt(pycurl.HTTPPROXYTUNNEL, 1)
rel_header = header or self.header
if rel_header:
crl.setopt(pycurl.HTTPHEADER, rel_header)
crl.fp = StringIO.StringIO()
if isinstance(url, unicode):
url = str(url)
crl.setopt(pycurl.URL, url)
crl.setopt(pycurl.HTTPPOST, data) # upload file
crl.setopt(crl.WRITEFUNCTION, crl.fp.write)
try:
crl.perform()
except Exception, e:
raise CurlException(e)
示例14: xcoinApiCall
# 需要导入模块: import pycurl [as 别名]
# 或者: from pycurl import VERBOSE [as 别名]
def xcoinApiCall(self, endpoint, rg_params):
# 1. Api-Sign and Api-Nonce information generation.
# 2. Request related information from the Bithumb API server.
#
# - nonce: it is an arbitrary number that may only be used once.
# - api_sign: API signature information created in various combinations values.
endpoint_item_array = {
"endpoint" : endpoint
}
uri_array = dict(endpoint_item_array, **rg_params) # Concatenate the two arrays.
str_data = urllib.parse.urlencode(uri_array)
nonce = self.usecTime()
data = endpoint + chr(0) + str_data + chr(0) + nonce
utf8_data = data.encode('utf-8')
key = self.api_secret
utf8_key = key.encode('utf-8')
h = hmac.new(bytes(utf8_key), utf8_data, hashlib.sha512)
hex_output = h.hexdigest()
utf8_hex_output = hex_output.encode('utf-8')
api_sign = base64.b64encode(utf8_hex_output)
utf8_api_sign = api_sign.decode('utf-8')
curl_handle = pycurl.Curl()
curl_handle.setopt(pycurl.POST, 1)
#curl_handle.setopt(pycurl.VERBOSE, 1) # vervose mode :: 1 => True, 0 => False
curl_handle.setopt(pycurl.POSTFIELDS, str_data)
url = self.api_url + endpoint
curl_handle.setopt(curl_handle.URL, url)
curl_handle.setopt(curl_handle.HTTPHEADER, ['Api-Key: ' + self.api_key, 'Api-Sign: ' + utf8_api_sign, 'Api-Nonce: ' + nonce])
curl_handle.setopt(curl_handle.WRITEFUNCTION, self.body_callback)
curl_handle.perform()
#response_code = curl_handle.getinfo(pycurl.RESPONSE_CODE) # Get http response status code.
curl_handle.close()
return (json.loads(self.contents))