0

I'm trying to import the Google HAR file, but this code I wrote gives me this error:

AttributeError: 'ProxyManger' object has no attribute '_ProxyManger__server'. Did you mean: '_ProxyManger__BMP'?

My codes:

import pprint
import time

from browsermobproxy import Server
from selenium import webdriver

class ProxyManger:

    __BMP = "C:/Users/Ender/Desktop/browsermob-proxy-2.1.4/bin/browsermob-proxy.bat"

    def __int__(self):
        self.__server = Server(ProxyManger.__BMP)
        self.__client = None

    def start_server(self):
        self.__server.start()
        return self.__server

    def start_client(self):

        self.__client = self.__server.create_proxy(params={"trustAllServers": "true"})
        return self.__client

    @property
    def client(self):
        return self.__client
    @property
    def server(self):
        return self.__server
if "__main__" == __name__:
    proxy = ProxyManger()
    server = proxy.start_server()
    client = proxy.start_client()
    client.new_har("google.com")
    print(client.proxy)
    options = webdriver.ChromeOptions()
    options.add_argument("--proxy-server={}".format(client.proxy))
    driver = webdriver.Chrome(chrome_options=options)
    driver.get("https://www.google.com/")
    time.sleep(3)

    pprint.pprint(client.har)
    server.stop()

I don't understand where I went wrong, what is the source of the problem and how do I need to fix it? I would be glad if you help. have a nice day

1

1 Answer 1

1

The __init__ function is written wrong, you have __int__ it's suposed to be __init__ since it does't enter the init function it does't create the _server atribute

Sign up to request clarification or add additional context in comments.

2 Comments

It worked, thanks, but the chrome window shows "Your connection is not private", how do I fix it?
Thanks i did it, i forgot add certificates on chrome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.