有没有一种简单的方法可以使用Python访问记录在某个特定区块高度的比特币区块中的所有交易? [英] Is there an easy way to access all transactions recorded in a bitcoin block with certain block height using Python?

查看:66
本文介绍了有没有一种简单的方法可以使用Python访问记录在某个特定区块高度的比特币区块中的所有交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不运行整个节点或下载几GB数据的情况下,以一定的块高检索一个块内的所有事务.

I would like to retrive all transactions within a block with a certain block height, without running a full node or downloading a few GB of data.

不坚持使用Python,尝试使用此内容的 Block Height 部分.按照此处给出的示例

Not sticking to Python, tried to use the Block Height section of this. Following the example given there,

https://blockchain.info/block-height/$100?format=json

返回:

Invalid Numerical Value

是否有一种简单的Python方式做到这一点?

Is there an easy, Pythonic way to do this?

推荐答案

您必须在没有 $ 的情况下使用,这只是 $ block_height 不属于url的信息,而是变量,您必须替换

You have to use without $ which was only information that $block_height is not part of url but variable which you have to replace,

https://blockchain.info/block-height/100?format=json


import requests

r = requests.get('https://blockchain.info/block-height/100?format=json')
data = r.json()

#print(r.text)
#print(data)
print(data['blocks'][0]['hash'])

这篇关于有没有一种简单的方法可以使用Python访问记录在某个特定区块高度的比特币区块中的所有交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆