因为目前使用的是模拟账户连接api,因此受到限制,api的account_token只能用于获取价格,不能用于下单,所以我希望通过模拟登录网页版交易平台,获取可用于下单的session_token,但是发现有两个url,一个是表面上的url,另一个是提交用户名和密码的url,我不知道应该用那个url,另外无论我用哪一个url,都会报错ValueError: Expecting value: line 1 column 1 (char 0),这好像是和utf-8有关,请大家帮忙,谢谢
程序:
import requests
import json
url = "https://trade.oanda.com/"
#另一个url:"https://fxgame-webapi.oanda.com/v1/user/login.json"
username = 'cawa11'
password = '1122334455'
params = {'username':username,'password':password}
headers = {'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip,deflate',
'charset':'utf-8',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
r = requests.get(url,headers = headers, params=params)
print(r.json())
报错:
Traceback (most recent call last):
File "C:\Users\lenovo\Desktop\oo.py", line 15, in <module>
print(r.json())
File "C:\Python34\lib\site-packages\requests-2.9.1-py3.4.egg\requests\models.py", line 808, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Python34\lib\json\__init__.py", line 318, in loads
return _default_decoder.decode(s)
File "C:\Python34\lib\json\decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
雷雷