def __init__(self,browser,cookies): import urllib2 self.browser = urllib2 if cookies != '': cj = set_cookies_from_text(cookies) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) self.browser.install_opener( opener)
def __init__(self, browser, cookies): from mechanize import Browser br = Browser() # Cookie Jar if cookies == "firefox": cj = getFirefoxCookie() else: cj = set_cookies_from_text(cookies) br.set_cookiejar(cj) # Browser options br.set_handle_equiv(True) #br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) # Debug Options #br.set_debug_http(True) #br.set_debug_redirects(True) #br.set_debug_responses(True) # Follows refresh 0 but not hangs on refresh > 0 br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # User-Agent br.addheaders = [ ('user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.45 Safari/537.36' ), ('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ) ] self.browser = br self.browserType = 'mechanize'
def __init__(self, browser, cookies): import urllib2 self.browser = urllib2 if cookies != '': cj = set_cookies_from_text(cookies) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) self.browser.install_opener(opener)
def __init__(self,browser,cookies): from mechanize import Browser br = Browser() # Cookie Jar if cookies == "firefox": cj = getFirefoxCookie() else: cj=set_cookies_from_text(cookies) br.set_cookiejar(cj) # Browser options br.set_handle_equiv(True) #br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) # Debug Options #br.set_debug_http(True) #br.set_debug_redirects(True) #br.set_debug_responses(True) # Follows refresh 0 but not hangs on refresh > 0 br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # User-Agent br.addheaders = [('user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.45 Safari/537.36'), ('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8')] self.browser = br self.browserType = 'mechanize'