raena-crawler-engine/hasaki_crawler_engine/test.py

28 lines
707 B
Python

from playwright.sync_api import sync_playwright
from fake_useragent import UserAgent
import logging
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
ua = UserAgent(platforms='mobile')
random_mobile_ua = ua.random
logging.info("using user agent: {}".format(random_mobile_ua))
context = browser.new_context(user_agent=random_mobile_ua)
page = context.new_page()
page.goto("https://hasaki.vn/san-pham/kem-duong-skin1004-lam-diu-da-chiet-xuat-rau-ma-75ml-89637.html")
page.reload()
with page.expect_response("**/wap/v2/product/detail**") as response:
api_requests = response.value.json()
browser.close()
print(api_requests)