2

I want to be able to monitor network requests when web-scraping using Selenium and Browsermob-Proxy in python but I'm unable to change the IP of my chrome browser so the requests going to the website aren't coming from my IP address and instead coming from an address that I set.

Is there a way I can have the requests coming from a different IP while it being intercepted by Browsermob-Proxy for me to monitor network data?

def create_browsermob_proxy():

  for proc in psutil.process_iter():
      # check whether the process name matches
      if proc.name() == "browsermob-proxy":
          proc.kill()

  dict = {'port': 8080}
  server = Server(path="C:/Path/To/File/browsermob-proxy.bat", options=dict)
  server.start()

  proxy = server.create_proxy()


  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_argument("--proxy-server={}".format(proxy.proxy))
  driver = webdriver.Chrome(chrome_options=chrome_options)

  proxy.new_har("google")
  driver.get("http://www.google.com")
  print(proxy.har)
John DeBritto
  • 129
  • 2
  • 11
  • Possible duplicate of [How does one configure a proxy upstream of browsermob on osx?](https://stackoverflow.com/questions/39459171/how-does-one-configure-a-proxy-upstream-of-browsermob-on-osx) – pguardiario Aug 20 '19 at 00:18

0 Answers0