0

Pythonを使用してトレントファイルのトラッカー情報を解析するコードを書いています。

import bencoder
import sys

target = './'+sys.argv[1]

with open(target, 'rb') as torrent_file:
    torrent = bencoder.decode(torrent_file.read())

i=0
while True:
    try:
        print(torrent[b'announce-list'][i])
        i+=1
    except:
        break
    

出力は次のとおりです。

[b'udp://tracker.openbittorrent.com:80/announce']

[b'udp://tracker.opentrackr.org:1337/announce']

以下のフォームの値を解析したいと思います。

[「tracker.openbittorrent.com」、80]

[「tracker.opentrackr.org」、1337]

どのように解析すればよいですか?

4

1 に答える 1