我编写了一个脚本,将其作为输入比特币地址,并从blockchain.info下载包含两个输入地址的交易的所有块。块总数:6013
问题是我经常遇到随机错误。我收到的最新错误:
requests.exceptions.ConnectionError :(“连接已中止。”,RemoteDisconnected(“远端封闭的无响应的连接”,))
我在崩溃之前存储了适当的变量值,以便下次可以从那里开始。
Idk是否相关,但是我过去经常获得500个状态代码。因此,每次发送500状态代码时,我都会将计时器设置为20英寸,然后再尝试再次连接服务器。
我将提供连接的代码。
for line in tmp:
words = line.split(",")
s = words[2]
s2 = words[1]
print("Block Index: ", s, "Block Height: ", s2)
with requests.Session() as keep_alive:
url = "https://blockchain.info/rawblock/" + str(s)
response = keep_alive.get(url, stream = True)
if response.status_code == 200:
print("Status code: ", response.status_code)
increase = 0
sc = response.status_code #status code
while sc == 500 or sc == 104:
print("Status code: ", response.status_code)
print("Server side message: ", response.text)
response.close()
t = 20
while t:
mins, secs = divmod(t, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
t -= 1
response = keep_alive.get(url, stream = True)
print("Status code: ", response.status_code)
data = response.json()
在这一点上,我不知道。