我正在尝试返回 api 的 url。即使我在interception_fun 函数中返回url,我也无法在hmm 函数中打印它
import asyncio
from pyppeteer import launch
async def interception_fun(response):
# Response logic goes here
url = response.url
return url
async def hmm():
browser = await launch(headless=False)
page = await browser.newPage()
await page.goto('https://jobs.chegg.com')
url = page.on('response', interception_fun)
print(url)
await browser.close()
return
asyncio.get_event_loop().run_until_complete(hmm())