39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from seleniumwire import webdriver
|
|
import random
|
|
from selenium.webdriver.chrome.service import Service
|
|
from webdriver_manager.chrome import ChromeDriverManager
|
|
|
|
# Set mobile emulation options
|
|
mobile_emulation = {
|
|
"deviceName": "iPhone X"
|
|
}
|
|
|
|
op = webdriver.ChromeOptions()
|
|
# hight = str(random.randint(640,1280))
|
|
# width = str(random.randint(1024,1920))
|
|
# op.add_argument("window-size="+width+","+hight+"")
|
|
op.add_experimental_option("useAutomationExtension", False)
|
|
op.add_argument('--no-sandbox')
|
|
op.add_argument('--disable-notifications')
|
|
op.add_argument("--lang=en-GB")
|
|
op.add_argument("--log-level=3")
|
|
op.headless = False
|
|
|
|
|
|
|
|
|
|
driver=webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=op)
|
|
|
|
# Access a website
|
|
driver.get('https://hasaki.vn')
|
|
|
|
# Get all requests made by the browser
|
|
for request in driver.requests:
|
|
if request.response:
|
|
if '/wap/v2/product/detail' in request.url:
|
|
iteminfo = request.response.body
|
|
print(iteminfo)
|
|
|
|
# Quit the driver
|
|
driver.quit()
|