本文整理汇总了Python中requests.Request.params方法的典型用法代码示例。如果您正苦于以下问题:Python Request.params方法的具体用法?Python Request.params怎么用?Python Request.params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests.Request
的用法示例。
在下文中一共展示了Request.params方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def setUp(self):
# mock request object
request = Request()
request.method = 'GET'
request.url = 'http://example.com/'
request.params = {}
request.data = {}
request.params_and_data = {}
self.request = request
# mock response object
response = Mock()
response.content = 'access_token=321'
response.headers = {'content-type': 'text/html; charset=UTF-8'}
response.ok = True
response.status_code = 200
self.response = response
# mock raise_for_status with an error
def raise_for_status():
raise Exception('Response not OK!')
self.raise_for_status = raise_for_status
# mock hook object
hook = Mock()
hook.consumer_key = '123'
hook.consumer_secret = '456'
hook.access_token = '321'
hook.access_token_secret = '654'
self.hook = hook
示例2: sendHttpRequest
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def sendHttpRequest(_args):
s = Session()
url = makeURL(_args)
req = Request(_args.get("method"), url)
if (_args.get("headers") is not None) : req.headers = _args.get("headers")
if (_args.get("auth") is not None) : req.auth = HTTPBasicAuth(_args.get("auth")[0], _args.get("auth")[1])
if (_args.get("params") is not None) : req.params = _args.get("params")
if (_args.get("cookies") is not None) : req.cookies = _args.get("cookies")
if (_args.get("data") is not None) : req.data = _args.get("data")
prepped = req.prepare()
if (_args.get("body") is not None) : prepped.body = _args.get("body")
# do something with prepped.body
# do something with prepped.headers
resp = s.send(prepped,timeout=_args.get("timeout"), proxies=_args.get("proxies"))
return resp
示例3: setUp
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def setUp(self):
# mock request object
request = Request()
request.method = 'GET'
request.url = 'http://example.com/'
request.headers = {}
request.params = {}
request.data = {}
request.params_and_data = {}
self.request = request
# mock consumer object
consumer = Mock()
consumer.key = '123'
consumer.secret = '456'
self.consumer = consumer
# mock token object
token = Mock()
token.key = '321'
token.secret = '456'
self.token = token
示例4: setUp
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def setUp(self):
# mock request object
request = Request()
request.method = 'GET'
request.url = 'http://example.com/'
request.headers = {}
request.params = {}
request.data = {}
request.params_and_data = {}
self.request = request
# mock response object
response = Mock()
response.content = 'access_token=321'
response.headers = {'content-type': 'text/html; charset=UTF-8'}
response.ok = True
response.status_code = 200
response.raise_for_status = lambda: None
self.response = response
# mock raise_for_status with an error
def raise_for_status():
raise Exception('Response not OK!')
self.raise_for_status = raise_for_status
# mock consumer object
consumer = Mock()
consumer.key = '123'
consumer.secret = '456'
self.consumer = consumer
# mock token object
token = Mock()
token.key = '321'
token.secret = '456'
self.token = token
示例5: base_request
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def base_request(api_key = API_KEY):
req = Request('GET')
req.params = {'api_key': API_KEY, 'per_page': 100}
req.url = BASE_URL
return req
示例6: Session
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
sess = Session()
sess.verify=False
req = Request('GET',
url,
auth=('[email protected]', 'M0bile-card'),
)
# _nocache=1455096934802&_nocache=1455096934802
req.params={
'FromDate':'01.02.2016',
'ToDate':'10.02.2016',
'DeviceIDs':'59157',
'ReconciliationStatus':'Any',
'ShowCompleted':'true',
'ShowDeclined':'true',
'ShowVoided':'true',
}
url='https://2can.ru/operations/payments'
prepped = sess.prepare_request(req)
resp = sess.send(prepped)
print resp.status_code
respf=codecs.open('resp.txt', 'w', 'utf-8')
respf.write(resp.text)
respf.close()
示例7: init_WalletDB
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import params [as 别名]
def init_WalletDB(self, ):
# CREATE TABLE customer(
# id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
# firstname VARCHAR(50),
# lastname VARCHAR(50),
# age INTEGER
# )
#
#
# 1Ce1NpJJAH9uLKMR37vzAmnqTjB4Ck8L4g l=34
# NXT-JTA7-B2QR-8BFC-2V222 l =24
# NXTxJTA7xB2QRx8BFCx2V222nxtnxtnxtx l =34
#
# NFD-AQQA-MREZ-U45Z-FWSZG l=24
# 15528161504488872648 l=20
#Longer answer: If you declare a column of a table to be INTEGER PRIMARY KEY, then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty.
#id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
wallet_is_new = not os.path.exists(self.walletDB_fName)
try:
nxtWallet_sqlite3_schema = """create table nxtWallet (
accountName text unique,
NxtNumeric VARCHAR(20) unique primary key,
NxtRS VARCHAR(24) unique,
NxtRS_BTC VARCHAR(34),
NxtSecret VARCHAR(96) unique,
Nxt_hasPubkey VARCHAR(5)
);
"""
# nxtWallet_sqlite3_schema = """create table nxtWallet (
# accountName text unique,
# NxtNumeric text primary key,
# NxtRS text unique,
# NxtRS_BTC text,
# NxtSecret text unique,
# Nxt_hasPubkey text
# );
# """
#
self.consLogger.info('creating wallet.db with filename: %s ', self.walletDB_fName )
self.walletDBConn = sq.connect(self.walletDB_fName)
self.walletDBCur = self.walletDBConn.cursor()
self.walletDBCur.execute(nxtWallet_sqlite3_schema)
sessionTemp = Session()
nxtSecret = self.genRanSec()
headers = {'content-type': 'application/json'}
getAccountId = {
"requestType" : "getAccountId" , \
"secretPhrase" : nxtSecret , \
"pubKey" : ""
}
NxtReqT = Req( method='POST', url = self.sessUrl, params = {}, headers = headers )
NxtReqT.params=getAccountId # same obj, only replace params
preppedReq = NxtReqT.prepare()
response = sessionTemp.send(preppedReq)
NxtResp = response.json()
# print("\n\n ------>" + str(NxtResp))
nxtNumAcc = NxtResp['account']
nxtRSAcc = NxtResp['accountRS']
NxtRS_BTC = NxtResp['accountRS']
NxtRS_BTC =NxtRS_BTC.replace("-","x")
NxtRS_BTC+='nxtnxtnxt'
# make sure it has no pubKey here!!!
# and if it has raise a huge alarm!
accName = ''
has_pubKey = 'N'
newNxtAccount = ( accName,nxtNumAcc ,nxtRSAcc ,NxtRS_BTC ,nxtSecret , has_pubKey)
insertNewNxtAccount = """insert into nxtWallet values ( ?,?,?,?,?,?)"""
self.walletDBCur.execute(insertNewNxtAccount, newNxtAccount )
self.walletDBConn.commit()
#http://stackoverflow.com/questions/11490100/no-autoincrement-for-integer-primary-key-in-sqlite3 shit.
testACCName = 'testAcc'
testNetAcc = '2865886802744497404' # <------testNet------------- FOR TESTING with non-existing accounts in wallet!!!
testNetAccRS = 'NXT-3P9W-VMQ3-9DRR-4EFKH'
testNetAccRS_BTC = testNetAccRS.replace("-","x")
testNetAccRS_BTC += 'nxtnxtnxt'
testNetAccSec = '' #
testACC = ( testACCName, testNetAcc , testNetAccRS,testNetAccRS_BTC ,testNetAccSec , 'Y' )
self.walletDBCur.execute(insertNewNxtAccount, testACC )
self.walletDBConn.commit()
testACCName = 'testAcc2'
testNetAcc = '16159101027034403504' # <------testNet------------- FOR TESTING with non-existing accounts in wallet!!!
testNetAccRS = 'NXT-L6PJ-SMZ2-5TDB-GA7J2'
testNetAccRS_BTC = testNetAccRS.replace("-","x")
testNetAccRS_BTC += 'nxtnxtnxt'
testNetAccSec = '' #
testACC = ( testACCName, testNetAcc , testNetAccRS,testNetAccRS_BTC ,testNetAccSec , 'Y' )
self.walletDBCur.execute(insertNewNxtAccount, testACC )
#.........这里部分代码省略.........