手動で "https://blockchain.info/tx/a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e" で、例えば文字列
からそれを読んで最後の64文字を読みます。送信コードは常に64文字です。
正規表現
あなたが送信-IDを読みたい、そこから複数のサービス/ウェブサイトをお持ちの場合は、送信-Idが文字列で始まり、その後から64個の文字を読み取った位置を保存することができますそこ。あなたが使用したいプログラミング言語を言いませんでしたので、私はC++の例を紹介します:
#include <iostream>
#include <string>
#include <vector>
#include <regex>
using namespace std;
struct PositionInString
{
PositionInString(string h, unsigned int p) : host(h), position(p) {}
string host;
unsigned int position;
};
int main()
{
vector<PositionInString> positions;
positions.push_back(PositionInString("blockchain.info", 27));
positions.push_back(PositionInString("btc.blockr.io", 30));
while(true)
{
string url;
cout << "Enter url: ";
cin >> url;
regex reg_ex("([a-z0-9|-]+\\.)*[a-z0-9|-]+\\.[a-z]+");
smatch match;
string extract;
if (regex_search(url, match, reg_ex))
{
extract = match[0];
}
else
{
cout << "Could not extract." << endl;
continue;
}
bool found = false;
for(auto& v : positions)
{
if(v.host.compare(extract) == 0)
{
cout << "Tx-Id: " << url.substr(v.position, 64) << endl;
found = true;
break;
}
}
if(found == false)
cout << "Unknown host \"" << extract << "\"" << endl;
}
return 0;
}
出力:スタックオーバーフローへ
Enter url: https://blockchain.info/tx/a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e
Tx-Id: a97aaf679880e079f80ddca53044b8cb3bd511014fb09bd28e33d5430dab4c8e
ようこそ!私は、あなたの質問の書式を編集して、読みやすさを向上させ、有益な回答を得る可能性を高めるかもしれません。 –