Open se162xg opened 4 years ago
import warnings
from selenium.webdriver import Chrome, ChromeOptions
warnings.filterwarnings(action='ignore', module='selenium')
opt = ChromeOptions()
opt.add_argument('--headless')
opt.add_argument('--disable-gpu')
opt.add_argument('--allow-running-insecure-content')
opt.add_argument("service_args=['–ignore-ssl-errors=true', '–ssl-protocol=TLSv1']")
opt.add_experimental_option('excludeSwitches', ['enable-automation'])
opt.add_argument('--blink-settings=imagesEnabled=false')
browser = Chrome(chrome_options=opt)
browser.get('https://example.com')
sleep(5)
print(browser.page_source)
browser.quit()
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.CHROME
capabilities["goog:loggingPrefs"] = {"performance": "ALL"}
browser = Chrome(chrome_options=opt, desired_capabilities=capabilities)
for entry in browser.get_log('performance'):
tmp = json.loads(entry['message'])
if tmp['message']['method']=='Network.requestWillBeSent':
print(tmp['message']['params']['request']['method'], tmp['message']['params']['request']['url'])