Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodriver uc.cdp.network.get_response_body() always returns None. #2088

Open
xiahan4956 opened this issue Nov 23, 2024 · 0 comments
Open

Nodriver uc.cdp.network.get_response_body() always returns None. #2088

xiahan4956 opened this issue Nov 23, 2024 · 0 comments

Comments

@xiahan4956
Copy link

xiahan4956 commented Nov 23, 2024

my purpose is to use Nodriver to get the response content .
But .cdp.network.get_response_body() always returns None.
This is my code.
I think my issue is similar as
#1788
#1930

import asyncio
import datetime
import time
import pandas as pd
import os
import sys
from tqdm import tqdm
import nodriver as uc

sys.path.append(os.getcwd())
from utils import run_no_driver


request_ids = []
async def response_meta_handler(event):
    # if 'https://api.follow.is/entries' in event.response.url:
    request_id = event.request_id
    request_ids.append(request_id) 
    print("add request_id", request_id)
    with open("data/nodriver.txt", "a") as f:
        f.write(str(event)+"\n")


async def run():       

    url =  "http://www.google.com/"
    driver = await run_no_driver()
    tab =  await driver.get("about:blank")
    
    tab.add_handler(uc.cdp.network.ResponseReceived, response_meta_handler)
    await tab.send(uc.cdp.target.set_auto_attach(True, True))
    tab =  await tab.get(url)
    await asyncio.sleep(10)

    for request_id in request_ids:
        print(request_id)
        a = await asyncio.wait_for(tab.send(uc.cdp.network.get_response_body(request_id)), timeout=10)
        b = await asyncio.wait_for(tab.send(uc.cdp.fetch.get_response_body(request_id)), timeout=10)
        
        print(a)
        print(b)
    
    print(123)
    print(123)
    print(123)
  
    
if __name__ == "__main__":
    asyncio.run(run())

In this code . I can get reuqest_id
like

add request_id 32460.14
add request_id 32460.15
add request_id 32460.11
add request_id 32460.19
add request_id 32460.20
add request_id 32460.18
add request_id 32460.17
add request_id 32460.10

But when I use uc.cdp.network.get_response_body(request_id) or uc.cdp.fetch.get_response_body(request_id)
I always get None like

32460.40
None
None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant