browsermob-proxy
browsermob-proxy copied to clipboard
When you set chrome_ options.add_ experimental_ When option ("debugger address", "127.0.0.1:9222"), the agent cannot get the request information?
When you set chrome_ options.add_ experimental_ When option ("debugger address", "127.0.0.1:9222"), the agent cannot get the request information?
chrome_options = Options() chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222") chrome_options.add_argument('--ignore-certificate-errors') chrome_options.add_argument('--proxy-server={0}'.format(proxy.proxy)) ... ... result = proxy.har result='{'log': {'version': '1.2', 'creator': {'name': 'BrowserMob Proxy', 'version': '2.1.4', 'comment': ''}, 'pages': [{'id': 'Page 0', 'startedDateTime': '2020-12-12T15:07:22.010+08:00', 'title': 'Page 0', 'pageTimings': {'comment': ''}, 'comment': ''}], 'entries': [], 'comment': ''}}'
entries is an empty array.
How to solve it ?
you should set these options in the beginning, just like this.
def cmd_process(url):
os.chdir('C:\Program Files (x86)\Google\Chrome\Application')
# you should set these options in this place
cmd_ = '''
chrome.exe --remote-debugging-port=9527 --user-data-dir="G:\Selenium_and_Chrome" --ignore-certificate-errors --proxy-server={0}'''.format(url)
os.system(cmd_)
server = Server(r"C:\\browsermob-proxy-2.1.4\bin\browsermob-proxy.bat")
server.start()
proxy = server.create_proxy()
url = parse.urlparse (proxy.proxy).path
sub = threading.Thread(target=cmd_process,args=(url,))
sub.start()
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9527")
driver = webdriver.Chrome(executable_path="chromedriver.exe", options=options)