def browser(honor_time=True, max_time=2, mobile_browser=False, user_agent=None, use_robust_parser=False, verify_ssl_certificates=True):
 from calibre.utils.browser import Browser
 if use_robust_parser:
  import mechanize
  opener = Browser(factory=mechanize.RobustFactory(), verify_ssl=verify_ssl_certificates)
 else:
  opener = Browser(verify_ssl=verify_ssl_certificates)
 opener.set_handle_refresh(True, max_time=max_time, honor_time=honor_time)
 opener.set_handle_robots(False)
 if (user_agent is None):
  user_agent = (USER_AGENT_MOBILE if mobile_browser else USER_AGENT)
 opener.addheaders = [('User-agent', user_agent)]
 proxies = get_proxies()
 to_add = {}
 http_proxy = proxies.get('http', None)
 if http_proxy:
  to_add['http'] = http_proxy
 https_proxy = proxies.get('https', None)
 if https_proxy:
  to_add['https'] = https_proxy
 if to_add:
  opener.set_proxies(to_add)
 return opener

def browser ( honor_time = True , max_time = 2 , mobile_browser = False , user_agent = None , use_robust_parser = False , verify_ssl_certificates = True ) : from calibre . utils . browser import Browser if use_robust_parser : import mechanize opener = Browser ( factory = mechanize . RobustFactory ( ) , verify_ssl = verify_ssl_certificates ) else : opener = Browser ( verify_ssl = verify_ssl_certificates ) opener . set_handle_refresh ( True , max_time = max_time , honor_time = honor_time ) opener . set_handle_robots ( False ) if ( user_agent is None ) : user_agent = ( USER_AGENT_MOBILE if mobile_browser else USER_AGENT ) opener . addheaders = [ ( 'User-agent' , user_agent ) ] proxies = get_proxies ( ) to_add = { } http_proxy = proxies . get ( 'http' , None ) if http_proxy : to_add [ 'http' ] = http_proxy https_proxy = proxies . get ( 'https' , None ) if https_proxy : to_add [ 'https' ] = https_proxy if to_add : opener . set_proxies ( to_add ) return opener
create a mechanize browser for web scraping .