Python

BrowserMob Proxy

Kyle79 2022. 12. 11. 14:50

 

 

https://browsermob-proxy-py.readthedocs.io/en/stable/

 

Welcome to BrowserMob Proxy’s documentation! — BrowserMob Proxy 0.6.0 documentation

Docs » Welcome to BrowserMob Proxy’s documentation! Edit on GitHub Welcome to BrowserMob Proxy’s documentation! Python client for the BrowserMob Proxy 2.0 REST API. How to install BrowserMob Proxy is available on PyPI, so you can install it with pip:

browsermob-proxy-py.readthedocs.io

 

 

 

https://github.com/lightbody/browsermob-proxy

 

GitHub - lightbody/browsermob-proxy: A free utility to help web developers watch and manipulate network traffic from their AJAX

A free utility to help web developers watch and manipulate network traffic from their AJAX applications. - GitHub - lightbody/browsermob-proxy: A free utility to help web developers watch and manip...

github.com

 

import settings

from browsermobproxy import Server
from selenium.webdriver import DesiredCapabilities

config = settings.Config

server = Server(config.BROWSERMOB_PATH)
server.start()
proxy = server.create_proxy()

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % proxy.proxy)
chrome_options.add_argument('--headless')

capabilities = DesiredCapabilities.CHROME.copy()
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True

driver = webdriver.Chrome(options=chrome_options,
    desired_capabilities=capabilities,
   executable_path=config.CHROME_PATH)

proxy.new_har("sahibinden", options={'captureHeaders': True})
driver.get("https://www.sahibinden.com/en")

entries = proxy.har['log']["entries"]
for entry in entries:
    if 'request' in entry.keys():
        print(entry['request']['url'])
        print(entry['request']['headers'])
        print('\n')

proxy.close()
driver.quit()

 

'Python' 카테고리의 다른 글

한글 인코딩 깨지는 경우  (0) 2023.03.02
Selenium Wire  (0) 2022.12.11
User-agent generator  (0) 2022.12.11
Selenium Wire Option  (2) 2022.12.11
Selenium Chrome Option  (0) 2022.12.11