所以我目前在蟒蛇麻烦移动蟒蛇请求node.js的请求
import requests
import json
address = "*address here*"
viewkey = "*viewkey here*"
headers = {'content-type': 'application/json'}
url = "https://api.mymonero.com:8443/get_address_txs"
data = {"address":address,"view_key":viewkey}
data = json.dumps(data)
response = requests.post(url, data=data, headers=headers)
print(response.text)
正常运行的代码和我想移动到到的NodeJS它我写
var request = require('request');
var options = {
url: 'https://api.mymonero.com:8443/get_address_txs',
headers: {'content-type': 'application/json'},
data: JSON.stringify({
address:"address",
viewkey:"viewkey"
})
};
request.post(options,function(error, response, body) {
console.log(body);
})
另一个程序整合
我认为代码将是相同的,但显然不是我从服务器获得第二段代码的错误。请有人可以帮我迁移吗?
注意:我知道python中的请求有一个json属性,为了清楚起见,我已经用python这样写了它。
为了记录我与JavaScript得到的回应是:
{
"Error": "Problems parsing JSON"
}
当我从蟒蛇得到:
{
"total_received": "152840132538",
"scanned_height": 2589644,
"scanned_block_height": 1320308,
"start_height": 2586111,
...
}
只是好奇,你为什么要将python转换为nodejs? – niceman
因为在Python中并不存在一堆很酷的库,并且不想永远移植它们。 –
hmmm酷库中的节点,例子? – niceman