26 lines
851 B
Python
26 lines
851 B
Python
|
import asyncio
|
||
|
from playwright.async_api import async_playwright
|
||
|
|
||
|
async def main():
|
||
|
async with async_playwright() as p:
|
||
|
browser = await p.chromium.launch()
|
||
|
context = await browser.new_context()
|
||
|
|
||
|
page = await context.new_page()
|
||
|
|
||
|
# Enable request interception
|
||
|
await page.route('https://hasaki.vn/wap/v2/product/detail', lambda route: route.continue_())
|
||
|
|
||
|
# Navigate to the website URL
|
||
|
await page.goto('https://hasaki.vn/san-pham/nuoc-hoa-hong-khong-mui-klairs-danh-cho-da-nhay-cam-180ml-65994.html')
|
||
|
|
||
|
# Wait for the API request to be made
|
||
|
response = await page.wait_for_event('request', predicate=lambda req: 'v2/product/detail' in req.url)
|
||
|
json_response = await response.response.json()
|
||
|
|
||
|
print(json_response)
|
||
|
|
||
|
await browser.close()
|
||
|
|
||
|
asyncio.run(main())
|