python3.x - python連oanda的模擬交易api獲取json問(wèn)題第七問(wèn)
問(wèn)題描述
因?yàn)槟壳笆褂玫氖悄M賬戶連接api,因此受到限制,api的account_token只能用于獲取價(jià)格,不能用于下單,所以我希望通過(guò)模擬登錄網(wǎng)頁(yè)版交易平臺(tái),獲取可用于下單的session_token,但是發(fā)現(xiàn)有兩個(gè)url,一個(gè)是表面上的url,另一個(gè)是提交用戶名和密碼的url,我不知道應(yīng)該用那個(gè)url,另外無(wú)論我用哪一個(gè)url,都會(huì)報(bào)錯(cuò)ValueError: Expecting value: line 1 column 1 (char 0),這好像是和utf-8有關(guān),請(qǐng)大家?guī)兔Γx謝程序:
import requestsimport jsonurl = 'https://trade.oanda.com/' #另一個(gè)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())
報(bào)錯(cuò):
Traceback (most recent call last): File 'C:UserslenovoDesktopoo.py', line 15, in <module> print(r.json()) File 'C:Python34libsite-packagesrequests-2.9.1-py3.4.eggrequestsmodels.py', line 808, in json return complexjson.loads(self.text, **kwargs) File 'C:Python34libjson__init__.py', line 318, in loads return _default_decoder.decode(s) File 'C:Python34libjsondecoder.py', line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File 'C:Python34libjsondecoder.py', line 361, in raw_decode raise ValueError(errmsg('Expecting value', s, err.value)) from NoneValueError: Expecting value: line 1 column 1 (char 0)
問(wèn)題解答
回答1:https://fxgame-webapi.oanda.com/v1/user/login.json?api_key=d39400e6d2f3c11a&password=1122334455&username=cawa11
相關(guān)文章:
1. boot2docker無(wú)法啟動(dòng)2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. docker-compose中volumes的問(wèn)題4. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.5. java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類6. nignx - docker內(nèi)nginx 80端口被占用7. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?8. dockerfile - 為什么docker容器啟動(dòng)不了?9. docker容器呢SSH為什么連不通呢?10. 關(guān)于docker下的nginx壓力測(cè)試

網(wǎng)公網(wǎng)安備