1def get_browser(self):
2 '''Returns a mechanize.Browser object configured with the framework's global options.'''
3 br = mechanize.Browser()
4 # set the user-agent header
5 br.addheaders = [('User-agent', self._global_options['user-agent'])]
6 # set debug options
7 if self._global_options['verbosity'] >= 2:
8 br.set_debug_http(True)
9 br.set_debug_redirects(True)
10 br.set_debug_responses(True)
11 # set proxy
12 if self._global_options['proxy']:
13 br.set_proxies({'http': self._global_options['proxy'], 'https': self._global_options['proxy']})
14 # additional settings
15 br.set_handle_robots(False)
16 # set timeout
17 socket.setdefaulttimeout(self._global_options['timeout'])
18 return br