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. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. docker-machine添加一個(gè)已有的docker主機(jī)問(wèn)題4. css - 求推薦適用于vue2的框架 像bootstrap這種類型的5. Span標(biāo)簽6. SessionNotFoundException:會(huì)話ID為null。調(diào)用quit()后使用WebDriver嗎?(硒)7. android新手一枚,android使用httclient獲取服務(wù)器端數(shù)據(jù)失敗,但是用java工程運(yùn)行就可以成功獲取。8. css - 關(guān)于div自適應(yīng)問(wèn)題,大家看圖吧,說(shuō)不清9. redis啟動(dòng)有問(wèn)題?10. java - Collections類里的swap函數(shù),源碼為什么要新定義一個(gè)final的List型變量l指向傳入的list?
