How to use the mechanize.Browser.__init__ function in mechanize

To help you get started, we’ve selected a few mechanize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inspirehep / inspire / tests / web_inspire_regression_tests.py View on Github external
def __init__(self, username, password, *args, **kwargs):
        # super(LoggedInBrowser, self).__init__(*args, **kwargs)
        mechanize.Browser.__init__(self, *args, **kwargs)
        self.set_handle_robots(False)
        login(self, username, password)
github zopefoundation / Zope / lib / python / Products / Five / testbrowser.py View on Github external
def __init__(self, *args, **kws):
        inherited_handlers = ['_unknown', '_http_error',
            '_http_request_upgrade', '_http_default_error', '_basicauth',
            '_digestauth', '_redirect', '_cookies', '_referer',
            '_refresh', '_equiv', '_gzip']

        self.handler_classes = {"http": PublisherHTTPHandler}
        for name in inherited_handlers:
            self.handler_classes[name] = mechanize.Browser.handler_classes[name]

        mechanize.Browser.__init__(self, *args, **kws)
github zopefoundation / Zope / src / Products / Five / testbrowser.py View on Github external
def __init__(self, *args, **kws):
        inherited_handlers = ['_unknown', '_http_error',
            '_http_request_upgrade', '_http_default_error', '_basicauth',
            '_digestauth', '_redirect', '_cookies', '_referer',
            '_refresh', '_equiv', '_gzip']

        self.handler_classes = {"http": PublisherHTTPHandler}
        for name in inherited_handlers:
            self.handler_classes[name] = mechanize.Browser.handler_classes[name]

        mechanize.Browser.__init__(self, *args, **kws)
github Mechazawa / REDBetter-crawler / whatbrowser.py View on Github external
def __init__(self, username, password, **kwargs):
        mechanize.Browser.__init__(self)

        self.tracker = "http://tracker.what.cd:34000/"
        for kwarg, value in kwargs.items():
            setattr(self, kwarg, value)

        self.set_handle_robots(False)
        self.open('http://what.cd/login.php')

        self.select_form(nr=0)
        self['username'] = username
        self['password'] = password
        self.submit()

        doc = parse_html(self._response.read())
        self.userid = re.search('[0-9]+$', \
                doc.cssselect('div#userinfo ul#userinfo_username li '
github Nandaka / PixivUtil2 / PixivBrowserFactory.py View on Github external
def __init__(self, config, cookie_jar):
        # fix #218 not applicable after upgrading to mechanize 4.x
        mechanize.Browser.__init__(self)

        self._configureBrowser(config)
        self._configureCookie(cookie_jar)
github laurentb / weboob / weboob / deprecated / browser / browser.py View on Github external
def __init__(self, firefox_cookies=None, parser=None, history=NoHistory(), proxy=None, logger=None, factory=None, responses_dirname=None):
        mechanize.Browser.__init__(self, history=history, factory=factory)
        self.logger = getLogger('browser', logger)
        self.responses_dirname = responses_dirname
        self.save_responses = responses_dirname is not None
        self.responses_count = 0

        self.addheaders = [
                ['User-agent', self.USER_AGENT]
            ]

        # Use a proxy
        self.proxy = proxy
        if proxy is not None:
            self.set_proxies(proxy)

        # Share cookies with firefox
        if firefox_cookies:
github malwaredllc / bamf / bamf.py View on Github external
def __init__(self, shodan_api=None):
        """
        Initialize a new Bamf instance

        `Optional`
        :param str shodan_api:  Shodan API key

        """
        mechanize.Browser.__init__(self)
        self._models = {}
        self._targets = {}
        self._devices = []
        self._threads = []
        self._backdoors = []
        self._queue = Queue.Queue()
        self._query = 'alphanetworks/2.23'
        self._ports = [8000, 8080, 8888]
        self._semaphore = threading.Semaphore(value=1)
        self._database = sqlite3.connect('database.db')
        self._database.executescript(self.__tbl_config)
        self._database.executescript(self.__tbl_routers)
        self._database.executescript(self.__tbl_devices)
        self._shodan = self._init_shodan(shodan_api)
        self.addheaders = [('User-Agent', 'xmlset_roodkcableoj28840ybtide')]
        self.set_handle_robots(False)
github sunshinelyz / python-hacker / com / binghe / hacker / tools / script / spy / mechainze_browser.py View on Github external
def __init__(self, proxies=[], user_agents=[]):
        mechanize.Browser.__init__(self)
        self.set_handle_robots(False)
        self.proxies = proxies
        self.user_agents = user_agents + ['Mozilla/4.0 ', 'FireFox/6.01', 'ExactSearch', 'Nokia7110/1.0']
        self.cookie_jar = cookielib.LWPCookieJar()
        self.set_cookiejar(self.cookie_jar)
        self.anonymize()