chrome得到的请求,53个
browsermob-proxy得到的请求,48个
我的代码
# _*_ coding:utf-8 _*_ from selenium import webdriver from selenium.webdriver.chrome.options import Options from browsermobproxy import Server import json from time import sleep try: # 启动代理 server = Server(r'/Users/renguanyu/app/browsermob-proxy/2.1.4/bin/browsermob-proxy') server.start() proxy = server.create_proxy() # 启动浏览器 chrome_options = Options() chrome_options.add_argument('--ignore-certificate-errors') chrome_options.add_argument('--proxy-server={0}'.format(proxy.proxy)) # chrome_options.add_argument('--headless') # 无头模式 browser = webdriver.Chrome(options=chrome_options) browser.implicitly_wait(60) # 监听结果 url = 'https://www.baidu.com/' proxy.new_har(options={ 'captureContent': True, 'captureHeaders': True }) browser.get(url) # 打印network result = proxy.har log = result["log"] entries = log["entries"] list = [] for entrie in entries: request = entrie["request"] request_url = request["url"] response = entrie["response"] status = response["status"] dict = { "url": request_url, "status": status } list.append(dict) # sleep(30) print("request_list",list) print("request_list_length",len(list)) finally: print("执行完毕,准备关闭程序") # sleep(3) # 关闭代理和浏览器 proxy.close() print("关闭代理") # browser.close() browser.quit() print("关闭浏览器")
标签:
browsermob-proxy
相关问题
- 为什么browsermob-proxy得到的request,会比chrome得到的request少?
- Browsermob proxy with selenium generates empty out
- Add ssl certificate to selenium-webdriver
- Python BrowserMob Proxy with IE captures incorrect
- Browsermob proxy sends Proxy-Authorization header
相关文章
- 为什么browsermob-proxy得到的request,会比chrome得到的request少?
- Add ssl certificate to selenium-webdriver
- Python BrowserMob Proxy with IE captures incorrect
- Browsermob proxy sends Proxy-Authorization header
- har file issue browsermob-proxy with webdriverio
- io.netty.handler.codec.TooLongFrameException: HTTP
- How to run BrowserMob Proxy with RobotFramework an
- How to fix 'Address already in use' error
你需要把所有请求对比。
比如本地缓存影响,比如请求拆分的影响等等
问题解决了,跟我本地的权限系统有关,如果是测试环境,就不会出现缺失请求的状况