불행히도 Warthunder Replay 파일은 쉽게 읽을 수있는 정보가 포함되어 있지 않은 것 같습니다 (예 : 일부 JSON 포함). 이것은 Farthunder Replay Files (.wrpl)를 파싱하는 매우 기본적인 시도입니다. WT-Tools가 있으며 (Multipart) 서버 재생과 함께 작동하지 않는 것 같습니다.
사용 가능한 세 가지 스크립트가 있습니다.
켈 자신의 위험에 따라 사용하면 스크래핑 (보호 된) 웹 페이지가 특정 국가의 TOS/법에 위배 될 수 있습니다.
이 스크립트는 https://warthunder.com/en/tournament/replay/ 페이지에서 재생을 긁는 데 사용될 수 있습니다. 다음과 같이 호출하십시오.
python replays_scraper.py <num_pages>
여기서 <num_pages> 는 스크랩 할 페이지 수입니다 (일반적으로 페이지 당 25 개 리플레이가 있습니다). 모든 발견 된 재생으로 JSON 객체를 인쇄합니다.
페이지가 로그인 되므로이 스크립트는 로그인을위한 쿠키가있는 auth_cookie.json 파일을 기대합니다.
auth_cookie.json :
{
"identity_sid" : " ... "
} 여기서 ... identity_sid 쿠키의 가치 (Warthunder.com에 로그인하고 브라우저에서 쿠키를 읽으면 얻을 수 있음).
https://warthunder.com/en/tournament/replay/에서 재생을 다운로드하십시오.
python download_replay.py <replay_id>
여기서 <replay_id> 는 Replay ID입니다 (64 비트, 10 진수 또는 16 진로). 이렇게하면 재생 파일을 hex 표기법으로 리플레이 ID의 이름을 따서 명명 된 폴더에 저장합니다.
폴더에 리플레이를 구문 분석하십시오
python parse_replay.py <replay_folder>
재생 파일의 이름이 0000.wrpl, 0001.wrpl 등으로 명명 될 것으로 예상됩니다. <replay_folder> 가 제공되지 않으면 현재 디렉토리를 사용합니다.
출력은 JSON 형태로됩니다.
parsing replay in /path/to/replay/005569aa001501ca
parsing /path/to/replay/005569aa001501ca/0000.wrpl
parsing /path/to/replay/005569aa001501ca/0001.wrpl
parsing /path/to/replay/005569aa001501ca/0002.wrpl
parsing /path/to/replay/005569aa001501ca/0003.wrpl
parsing /path/to/replay/005569aa001501ca/0004.wrpl
parsing /path/to/replay/005569aa001501ca/0005.wrpl
parsing /path/to/replay/005569aa001501ca/0006.wrpl
parsing /path/to/replay/005569aa001501ca/0007.wrpl
parsing /path/to/replay/005569aa001501ca/0008.wrpl
parsing /path/to/replay/005569aa001501ca/0009.wrpl
{
"level": "levels/avg_normandy.bin",
"mission_file": "gamedata/missions/cta/tanks/normandy/normandy_dom.blk",
"mission_name": "normandy_Dom",
"time_of_day": "day",
"weather": "hazy",
"time_of_battle_ts": 1641217514,
"time_of_battle": "2022-01-03 14:45:14",
"num_players": 21,
"players": [
{
"player_id": 34,
"vehicles": [
"us_m1a1_abrams",
"us_m1a1_hc_abrams"
]
},
{
"player_id": 35,
"vehicles": [
"us_m1_ip_abrams",
"us_hstv_l"
]
},
...
]
}
스크립트를 모듈로 사용할 수도 있습니다
import replays_scraper
import download_replay
import parse_replay
# set the cookies
cookies = { "identity_sid" : "secret_key" }
# download the html
pages = replays_scraper . download_pages ( 1 , cookies )
# scrape replay data from html
replays = []
for page in pages :
replays += replays_scraper . parse_page ( page )
# download the files of the last replay
download_replay . downloadReplay ( replays [ - 1 ][ "id" ])
# get the hexadecimal id (= folder name)
replay_id_hex = download_replay . _get_hex_id ( replays [ - 1 ][ "id" ])
# parse the replay
print ( parse_replay . parse_replay ( replay_id_hex ))