Chrome Devtools Protocoll Network.getResponseBody() not working

i’m using a Python library called Nodriver to do web automation, this library is based on CDP and i implemented a network monitor which analyzes incoming requests, select the one for which i want to look at the response, wait for it to finish loading and then get its response body.

This is the script:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> def request_handler(event: cdp.network.RequestWillBeSent, request_ids: list[cdp.network.RequestId]):
"""track AJAX request used for double check before paying bet"""
if event.request.url != "https://webapi.microgame.it/v2/Sport/Schedule/live": return
print(event.request_id, event.request.url)
request_ids.append(event.request_id)
## network monitor
failed_response_ids: list[cdp.network.RequestId] = []
response_ids: list[cdp.network.RequestId] = []
request_ids: list[cdp.network.RequestId] = []
await page.send(cdp.network.enable())
page.add_handler(cdp.network.RequestWillBeSent, lambda event: request_handler(event, request_ids))
page.add_handler(cdp.network.LoadingFinished, lambda event: response_ids.append(event.request_id) if event.request_id in request_ids else None )
page.add_handler(cdp.network.LoadingFailed, lambda event: failed_response_ids.append(event.request_id) if event.request_id in request_ids else None )
</code>
<code> def request_handler(event: cdp.network.RequestWillBeSent, request_ids: list[cdp.network.RequestId]): """track AJAX request used for double check before paying bet""" if event.request.url != "https://webapi.microgame.it/v2/Sport/Schedule/live": return print(event.request_id, event.request.url) request_ids.append(event.request_id) ## network monitor failed_response_ids: list[cdp.network.RequestId] = [] response_ids: list[cdp.network.RequestId] = [] request_ids: list[cdp.network.RequestId] = [] await page.send(cdp.network.enable()) page.add_handler(cdp.network.RequestWillBeSent, lambda event: request_handler(event, request_ids)) page.add_handler(cdp.network.LoadingFinished, lambda event: response_ids.append(event.request_id) if event.request_id in request_ids else None ) page.add_handler(cdp.network.LoadingFailed, lambda event: failed_response_ids.append(event.request_id) if event.request_id in request_ids else None ) </code>
    def request_handler(event: cdp.network.RequestWillBeSent, request_ids: list[cdp.network.RequestId]):
       """track AJAX request used for double check before paying bet""" 
       if event.request.url != "https://webapi.microgame.it/v2/Sport/Schedule/live": return
       print(event.request_id, event.request.url)
       request_ids.append(event.request_id)

    ## network monitor
    failed_response_ids: list[cdp.network.RequestId] = []
    response_ids: list[cdp.network.RequestId] = []
    request_ids: list[cdp.network.RequestId] = []
    await page.send(cdp.network.enable())
    page.add_handler(cdp.network.RequestWillBeSent, lambda event: request_handler(event, request_ids))
    page.add_handler(cdp.network.LoadingFinished, lambda event: response_ids.append(event.request_id) if event.request_id in request_ids else None )
    page.add_handler(cdp.network.LoadingFailed, lambda event: failed_response_ids.append(event.request_id) if event.request_id in request_ids else None )

I’m using this method on different websites and different requests. but this one in particular [request link][1] gives me trouble when retrieving the responnse body trough

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>response_id = response_ids[-1]
response = await page.send(cdp.network.get_response_body(response_id))
</code>
<code>response_id = response_ids[-1] response = await page.send(cdp.network.get_response_body(response_id)) </code>
response_id = response_ids[-1]
response = await page.send(cdp.network.get_response_body(response_id))

I want to specify that my script works for all the other websites and request, so i’m assuming it must be something in this specific request.
This are the request/response headers, as you can see it is a cross origin request made to an api and the response should be a json dict containing the data i’m searching for.

request headers:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>GET /v2/Sport/LiveOdds/all-248/all/principali_live/all HTTP/2
Host: webapi.microgame.it
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.playmatika.it/
Content-Type: text/plain
Origin: https://www.playmatika.it
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Sec-GPC: 1
TE: trailers
</code>
<code>GET /v2/Sport/LiveOdds/all-248/all/principali_live/all HTTP/2 Host: webapi.microgame.it User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Referer: https://www.playmatika.it/ Content-Type: text/plain Origin: https://www.playmatika.it Connection: keep-alive Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site Sec-GPC: 1 TE: trailers </code>
GET /v2/Sport/LiveOdds/all-248/all/principali_live/all HTTP/2
Host: webapi.microgame.it
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.playmatika.it/
Content-Type: text/plain
Origin: https://www.playmatika.it
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Sec-GPC: 1
TE: trailers

response headers:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>HTTP/2 200
content-type: application/json; charset=utf-8
content-encoding: gzip
access-control-allow-origin: https://www.playmatika.it
content-length: 26450
cache-control: max-age=8
date: Sat, 04 May 2024 14:02:59 GMT
vary: Accept-Encoding
server-timing: cdn-cache; desc=HIT
server-timing: edge; dur=1
mg-akamai-debug: Controller Sport (TOP Live)
vary: Referer
vary: Referer
server-timing: ak_p; desc="1714831379410_34608873_1111684016_31_4878_8_0_21";dur=1
X-Firefox-Spdy: h2
</code>
<code>HTTP/2 200 content-type: application/json; charset=utf-8 content-encoding: gzip access-control-allow-origin: https://www.playmatika.it content-length: 26450 cache-control: max-age=8 date: Sat, 04 May 2024 14:02:59 GMT vary: Accept-Encoding server-timing: cdn-cache; desc=HIT server-timing: edge; dur=1 mg-akamai-debug: Controller Sport (TOP Live) vary: Referer vary: Referer server-timing: ak_p; desc="1714831379410_34608873_1111684016_31_4878_8_0_21";dur=1 X-Firefox-Spdy: h2 </code>
HTTP/2 200 
content-type: application/json; charset=utf-8
content-encoding: gzip
access-control-allow-origin: https://www.playmatika.it
content-length: 26450
cache-control: max-age=8
date: Sat, 04 May 2024 14:02:59 GMT
vary: Accept-Encoding
server-timing: cdn-cache; desc=HIT
server-timing: edge; dur=1
mg-akamai-debug: Controller Sport (TOP Live)
vary: Referer
vary: Referer
server-timing: ak_p; desc="1714831379410_34608873_1111684016_31_4878_8_0_21";dur=1
X-Firefox-Spdy: h2

I also tried usging cdp.Network.replayXHR() but the request has sttaus code of 200 and the website which fires it is able to retrieve the response and update their websites. So using replayXHR() did nothing.
[1]: https://webapi.microgame.it/v2/Sport/Schedule/live

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật