예제 #1
0
 def login(self, usuario, password):
     try:
         with open('cookies.txt'):
             pass
     except IOError:
         cookies = LWPCookieJar('cookies.txt')
         cookies.save()
     url = 'https://www.crunchyroll.com/login'
     cookies = self.scraper
     cookies.cookies = LWPCookieJar('cookies.txt')
     page = self.scraper.get(url).content
     page = BeautifulSoup(page)
     hidden = page.findAll("input", {u"type": u"hidden"})
     hidden = hidden[1].get("value")
     logindata = {
         'formname': 'login_form',
         'fail_url': 'http://www.crunchyroll.com/login',
         'login_form[name]': usuario,
         'login_form[password]': password,
         'login_form[_token]': hidden,
         'login_form[redirect_url]': '/'
     }
     req = self.scraper.post(url, data=logindata)
     url = "http://www.crunchyroll.com"
     html = self.scraper.get(url).content
     if re.search(usuario + '(?i)', html):
         print 'You have been successfully logged in.\n\n'
         cookies.cookies.save()
     else:
         print 'Failed to verify your username and/or password. Please try again.\n\n'
         cookies.cookies.save()
예제 #2
0
def getTVPCookieJar(updatedUName=False):
    cookieJar = None
    print 'updatedUName', updatedUName
    try:
        cookieJar = LWPCookieJar()
        if not updatedUName:
            cookieJar.load(TVPCOOKIEFILE, ignore_discard=True)
    except:
        cookieJar = None

    if not cookieJar:
        cookieJar = LWPCookieJar()
    return cookieJar
예제 #3
0
파일: sync.py 프로젝트: gnumaniac/pulse
    def request(self, host, handler, request_body, verbose=0):
        # issue XML-RPC request
        h = self.make_connection(host)
        if verbose:
            h.set_debuglevel(1)

        self.send_request(h, handler, request_body)
        self.send_host(h, host)
        self.send_user_agent(h)

        self.send_content(h, request_body)

        r = h.getresponse()
        errcode = r.status
        errmsg = r.reason
        headers = r.msg

        # Creati g cookie jar
        cresponse = CookieResponse(headers)
        crequest = CookieRequest('https://' + host + '/')
        if '<methodName>base.ldapAuth</methodName>' in request_body:
            cj = LWPCookieJar()
            cj.extract_cookies(cresponse, crequest)
            if len(cj):
                cj.save(COOKIES_FILE, ignore_discard=True, ignore_expires=True)
                os.chmod(COOKIES_FILE, stat.S_IRUSR | stat.S_IWUSR)

        if errcode != 200:
            raise xmlrpclib.ProtocolError(host + handler, errcode, errmsg,
                                          headers)

        self.verbose = verbose

        return self.parse_response(r)
예제 #4
0
    def __init__(self, args):
        self.quiet = args.quiet
        self.columns = args.columns or terminal_width()
        self.user = args.user
        self.password = args.password
        self.passwordcmd = args.passwordcmd
        self.skip_auth = args.skip_auth

        cookie_file = os.path.join(os.environ['HOME'], DEFAULT_COOKIE_FILE)
        self.cookiejar = LWPCookieJar(cookie_file)

        try:
            self.cookiejar.load()
        except IOError:
            pass

        if getattr(args, 'encoding'):
            self.enc = args.encoding
        else:
            try:
                self.enc = locale.getdefaultlocale()[1]
            except:
                self.enc = 'utf-8'
            if not self.enc:
                self.enc = 'utf-8'

        self.log("Using %s " % args.base)
        self.bz = BugzillaProxy(args.base, cookiejar=self.cookiejar)
예제 #5
0
    def __init__(self, info=None):
        self._counter = 0
        self._cookies_filename = ''
        self._cookies = LWPCookieJar()
        self.user_agent = USER_AGENT
        self.info = info
        self.proxy_type = None
        self.proxy_url = None
        self.content = None
        self.status = None
        self.headers = dict()

        if get_setting("use_elementum_proxy", bool):
            elementum_addon = xbmcaddon.Addon(id='plugin.video.elementum')
            if elementum_addon and elementum_addon.getSetting('internal_proxy_enabled') == "true":
                self.proxy_url = "{0}://{1}:{2}".format("http", "127.0.0.1", "65222")
                if info and "internal_proxy_url" in info:
                    log.debug("Use Internal Elementum Proxy")
                    self.proxy_url = info["internal_proxy_url"]
            if elementum_addon.getSetting("proxy_enabled") == "true" and get_setting("use_proxy_setting", bool):
                self.proxy_type = int(elementum_addon.getSetting("proxy_type"))
                log.debug("Use users proxy from elementum settings: {0}".format(proxy_types[self.proxy_type]))
                prx_host = elementum_addon.getSetting("proxy_host")
                prx_port = elementum_addon.getSetting("proxy_port")
                self.proxy_url = "{0}://{1}:{2}".format(proxy_types[self.proxy_type], prx_host, prx_port)
예제 #6
0
 def download(self,url=""):
     if url == "":
         url = self.url
     else:
         url = url
     try:
             with open('cookies.txt'): pass
     except (OSError, IOError):
             cookies = LWPCookieJar('cookies.txt')
             cookies.save()      
     cookies = self.scraper
     cookies.cookies = LWPCookieJar('cookies.txt')
     cookies.cookies.load()
     html = self.scraper.get(url).content
     cookies.cookies.save()
     return html
예제 #7
0
 def downloadHtml(self, url, login=[False, None, None]):
     self.code = ""
     self.cookies()
     try:
         cookies = self.scraper
         cookies.cookies = LWPCookieJar('cookies.txt')
         cookies.cookies.load()
         if login[0]:
             data = {
                 'formname': 'RpcApiUser_Login',
                 'fail_url': 'http://www.crunchyroll.com/login',
                 'name': login[1],
                 'password': login[2]
             }
             response = self.scraper.post(url, data=data)
             html = self.scraper.get("http://www.crunchyroll.com").content
             if re.search(login[1] + '(?i)', html):
                 cookies.cookies.save()
                 return True
             else:
                 return False
         else:
             html = self.scraper.get(url).content
         cookies.cookies.save()
         return html
     except urllib2.HTTPError, e:
         self.addError("Crunchyroll: Error - %s." % e.code)
         self.code = e.code
예제 #8
0
    def __init__(self, args):
        self.modulus = None
        self.exponent = None
        self.args = args
        self.jar = j = LWPCookieJar()

        if self.args.skip_cert:
            try:
                _create_unverified_https_context = ssl._create_unverified_context
            except AttributeError:
                # Legacy Python that doesn't verify HTTPS certificates by default
                pass
            else:
                # Handle target environment that doesn't support HTTPS verification
                ssl._create_default_https_context = _create_unverified_https_context

        self.has_cookies = False
        if self.args.cookiefile:
            self.has_cookies = True
            try:
                j.load(self.args.cookiefile, ignore_discard=True)
            except IOError:
                self.has_cookies = False
        self.opener = build_opener(HTTPCookieProcessor(j))
        self.nextfile = args.file
예제 #9
0
    def login(self, login_callback, check_login_callback):
        global DEBUG_HTTP
        if connection.offline:
            raise Exception("Can't connect in offline mode.")
        if self.username == '' or self.password == '':
            raise Exception(
                "Please configure your username/password and restart the application"
            )
        logger.info("Checking Login status")
        from cookielib import LWPCookieJar
        cj = LWPCookieJar(self.cookiefile)

        if not self.opener_installed:
            from urllib2 import build_opener, install_opener, HTTPCookieProcessor, HTTPHandler
            if DEBUG_HTTP:
                opener = build_opener(HTTPHandler(debuglevel=1),
                                      HTTPCookieProcessor(cj))
            else:
                opener = build_opener(HTTPCookieProcessor(cj))
            install_opener(opener)
            self.opener_installed = True

        try:
            cj.load()
            logger.info("Loaded cookie file")
        except IOError, e:
            logger.info("Couldn't load cookie file")
예제 #10
0
파일: auth32p.py 프로젝트: csavage5/mylar
        def __init__(self, un, pw, session_path=None):
            '''
                Params:
                    un: account username (required)
                    pw: account password (required)
                    session_path: the path to the actual file you want to persist your cookies in
                                If blank, saves to $HOME/.32p_cookies.dat

            '''
            self.module = '[32P-AUTHENTICATION]'
            try:
                self.ses = cfscrape.create_scraper(delay=15)
            except Exception as e:
                logger.error('%s Can\'t create session with cfscrape' %
                             self.module)

            self.session_path = session_path if session_path is not None else os.path.join(
                mylar.CONFIG.SECURE_DIR, ".32p_cookies.dat")
            self.ses.cookies = LWPCookieJar(self.session_path)
            if not os.path.exists(self.session_path):
                logger.fdebug(
                    '%s Session cookie does not exist. Signing in and Creating.'
                    % self.module)
                self.ses.cookies.save()
            else:
                logger.fdebug(
                    '%s Session cookie found. Attempting to load...' %
                    self.module)
                self.ses.cookies.load(ignore_discard=True)
            self.un = un
            self.pw = pw
            self.authkey = None
            self.passkey = None
            self.uid = None
            self.inkdrops = None
예제 #11
0
    def __init__(self, config=None, **kw):
        """
        Setup credentials, read local data and setup network connection
        environment. Optionally sync with service on startup.

        Does not take positional arguments. Keyword arguments can either be
        given individually (username, password, initsync) or as an
        ac_config() instance. This will not be retained.

        In the latter form we support some additional command line options.
        """

        self.internalname = self.__class__.__name__.lower()

        # When the architecture stabilizes, switch to config as the sole
        # positional argument, and retain it instead of copying parts.
        # That would also enable reconfiguration at runtime.
        self.setConfig(config or BaseConfig(), **kw)

        # setup cookie handler
        self.opener = urllib2.build_opener(
                        urllib2.HTTPCookieProcessor(LWPCookieJar()))
        self.opener.addheaders = [('User-Agent', u'Anichou/{0} {1}'.format(
                        self.__class__.__name__, settings.VERSION))]
        self._logined = None

        if self.initsync:
            self.sync()
예제 #12
0
파일: auth32p.py 프로젝트: hjone72/mylar
        def __init__(self, un, pw, session_path=None):
            '''
                Params:
                    un: account username (required)
                    pw: account password (required)
                    session_path: the path to the actual file you want to persist your cookies in
                                If blank, saves to $HOME/.32p_cookies.dat

            '''
            self.module = '[32P-AUTHENTICATION]'
            self.ses = requests.Session()
            self.session_path = session_path if session_path is not None else os.path.join(
                mylar.CACHE_DIR, ".32p_cookies.dat")
            self.ses.cookies = LWPCookieJar(self.session_path)
            if not os.path.exists(self.session_path):
                logger.fdebug(
                    self.module +
                    ' Session cookie does not exist. Signing in and Creating.')
                self.ses.cookies.save()
            else:
                logger.fdebug(self.module +
                              ' Session cookie found. Attempting to load...')
                self.ses.cookies.load(ignore_discard=True)
            self.un = un
            self.pw = pw
            self.authkey = None
            self.passkey = None
            self.uid = None
예제 #13
0
 def initialize_cookie_jar(self):
     """Load cookies from disk, creating a new file if needed."""
     self.cookies = LWPCookieJar(self.cfg['cookie_jar_path'])
     if not os.path.exists('cookiejar'):
         # Create a new cookies file and set our Session's cookies
         self.cookies.save()
     self.cookies.load(ignore_discard=True)
예제 #14
0
def http_req(url, data=None, headers={}, cookie=None):
    if cookie:
        cj = LWPCookieJar()
        
        if os.path.isfile(cookie):
            cj.load(cookie, ignore_discard=True)
        
        opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj))
        urllib2.install_opener(opener)
    
    if data is not None:
        data = urllib.urlencode(data)
    
    req = urllib2.Request(url, data)
    
    for k, v in common.HEADERS.items():
        req.add_header(k, v)
    
    if headers:
        for k, v in headers.items():
            req.add_header(k, v)
    
    conn = urllib2.urlopen(req)
    
    if cookie:
        cj.save(cookie, ignore_discard=True)
    
    return conn
예제 #15
0
    def login(self):
        if not self.settings.getSetting('logged_in'):
            self.common.log('Logging in')

            username = self.settings.getSetting('username')
            password = self.settings.getSetting('password')

            self.gmusicapi.login(username, password)

            if not self.gmusicapi.is_authenticated():
                self.common.log("Login failed")
                self.settings.setSetting('logged_in', "")
                dialog = self.xbmcgui.Dialog()
                dialog.ok(self.language(30101), self.language(30102))
            else:
                self.common.log("Login succeeded")
                self.gmusicapi.session.cookies.save(filename=self._cookie_file,
                                                    ignore_discard=True)
                self.settings.setSetting('logged_in', "1")
        else:
            from cookielib import LWPCookieJar

            self.common.log("Loading cookie from file")
            self.gmusicapi.session.cookies = LWPCookieJar()
            self.gmusicapi.session.cookies.load(filename=self._cookie_file,
                                                ignore_discard=True)
            self.gmusicapi.session.logged_in = True
예제 #16
0
def start(args):
    """Login and session handler
    """
    # create cookiejar
    args._cj = LWPCookieJar()

    # lets urllib handle cookies
    opener = build_opener(HTTPCookieProcessor(args._cj))
    opener.addheaders = [(
        "User-Agent",
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36"
    ), ("Accept-Encoding", "identity"), ("Accept-Charset", "utf-8"),
                         ("DNT", "1")]
    install_opener(opener)

    # load cookies
    try:
        args._cj.load(getCookiePath(args), ignore_discard=True)
    except IOError:
        # cookie file does not exist
        pass

    args._cj.set_cookie(
        Cookie(0, "timezoneoffset", str(timezone // 60), None, False,
               "www.wakanim.tv", False, False, "/", True, False, None, False,
               None, None, {"HttpOnly": None}, False))
예제 #17
0
def stage4(username, password, push_dict):
    """ Test and fix _push_list """

    print '----------------'
    print 'starting stage 4'
    print '----------------'

    print 'atepmting to push 2 changes:', push_dict.keys()

    from cookielib import LWPCookieJar
    from urllib2 import build_opener, install_opener, \
     HTTPCookieProcessor

    # setup cookie handler
    opener = build_opener(HTTPCookieProcessor(LWPCookieJar()))
    install_opener(opener)

    if _login(username, password):
        if _push_list(push_dict):
            print 'enries pushed'
            print 'don\'t forget to reset the list ^^'
            print 'stage 4 completed'
        else:
            print 'PUSHING FAILED'
            _exit(1)
    else:
        print 'LOGIN FAILED, CHECK CREDENTIALS!'
        _exit(1)
예제 #18
0
    def _get_cookiejar(self):
        """Return a LWPCookieJar object loaded from our .cookies file.

        The same .cookies file is returned every time, located in the project
        root, same directory as config.yml and bot.py. If it doesn't exist, we
        will create the file and set it to be readable and writeable only by
        us. If it exists but the information inside is bogus, we'll ignore it.

        This is normally called by _make_site_object() (in turn called by
        get_site()), and the cookiejar is passed to our Site's constructor,
        used when it makes API queries. This way, we can easily preserve
        cookies between sites (e.g., for CentralAuth), making logins easier.
        """
        if self._cookiejar:
            return self._cookiejar

        self._cookiejar = LWPCookieJar(self._cookie_file)

        try:
            self._cookiejar.load()
        except LoadError:
            pass  # File contains bad data, so ignore it completely
        except IOError as e:
            if e.errno == errno.ENOENT:  # "No such file or directory"
                # Create the file and restrict reading/writing only to the
                # owner, so others can't peak at our cookies:
                open(self._cookie_file, "w").close()
                chmod(self._cookie_file, stat.S_IRUSR|stat.S_IWUSR)
            else:
                raise

        return self._cookiejar
예제 #19
0
def performTVPLogin():
    cookieJar = LWPCookieJar()
    try:
        
        url="https://tvplayer.com/account"
        username=ADDON.getSetting( "tvpusername" ) 
        if username=="": return False,cookieJar
        pwd=ADDON.getSetting( "tvppwd" ) 
        lasstusername=ADDON.getSetting( "lasttvpusername" )
        lasstpwd=ADDON.getSetting( "lasttvppwd" )         
        cookieJar=getTVPCookieJar(lasstusername!=username or lasstpwd!= pwd)
        mainpage = open_url(url,cj=cookieJar)
        

        if 'Login to TVPlayer' in mainpage:
            token   = urllib.unquote(re.findall('name="token" value="(.*?)"' ,mainpage)[0])
            print 'LOGIN NOW'
            url="https://tvplayer.com/account/login"
            headers={'Referer':"https://tvplayer.com/account/login",'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36','Origin':'https://tvplayer.com'}            
            post = {'email':username,'password':pwd,'token':token}
            post = urllib.urlencode(post)
            mainpage = open_url(url,cj=cookieJar,data=post,headers=headers )
            cookieJar.save (TVPCOOKIEFILE,ignore_discard=True)
            ADDON.setSetting( id="lasttvpusername" ,value=username)
            ADDON.setSetting( id="lasttvppwd" ,value=pwd)
        
        return not '>Login</a>' in mainpage,cookieJar
    except: 
            traceback.print_exc(file=sys.stdout)
    return False,cookieJar
예제 #20
0
    def login(self, username=None, password=None, is_beta=False):
        if (not username or not password):
            if not self.credentials:
                raise CredentialsError()
            else:
                credentials = self.credentials
        else:
            credentials = {
                'email': username,
                'password': password,
                'beta': is_beta
            }

        if self.credentials == credentials and self.state == Session.STATE_OK:
            return  # already logged in

        if not self.credentials or self.credentials['email'] != credentials[
                'email'] or self.credentials['beta'] != credentials['beta']:
            # changed account
            self.close()
            self.session = requests.Session()
            self.session.headers[
                'User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257'
            cookiefile = join(
                config.app_dir, 'cookies-%s.txt' %
                hashlib.md5(credentials['email']).hexdigest())
            if not isfile(cookiefile) and isfile(
                    join(config.app_dir, 'cookies.txt')):
                os.rename(join(config.app_dir, 'cookies.txt'),
                          cookiefile)  # migration from <= 2.25
            self.session.cookies = LWPCookieJar(cookiefile)
            try:
                self.session.cookies.load()
            except IOError:
                pass

        self.server = credentials['beta'] and SERVER_BETA or SERVER_LIVE
        self.credentials = credentials
        self.state = Session.STATE_INIT
        try:
            r = self.session.post(self.server + URL_LOGIN,
                                  data=self.credentials,
                                  timeout=timeout)
        except:
            if __debug__: print_exc()
            raise ServerError()

        if r.status_code != requests.codes.ok or 'server error' in r.text:
            self.dump(r)
            raise ServerError()
        elif r.url == self.server + URL_LOGIN:  # would have redirected away if success
            self.dump(r)
            raise CredentialsError()
        elif r.url == self.server + URL_CONFIRM:  # redirected to verification page
            self.state = Session.STATE_AUTH
            raise VerificationRequired()
        else:
            self.state = Session.STATE_OK
            return r.status_code
예제 #21
0
 def __init__(self):
     self._counter = 0
     self._cookies_filename = ''
     self._cookies = LWPCookieJar()
     self.user_agent = USER_AGENT
     self.content = None
     self.status = None
     self.headers = dict()
예제 #22
0
    def __init__(self, data_path, session=None):
        cookies_file = os.path.join(
            data_path, FILE_COOKIES_NAME)  # Define path to cookies file
        self.session = session if session else requests.Session()
        self.session.cookies = LWPCookieJar(cookies_file)

        # Load cookies if file exists
        if os.path.isfile(cookies_file):
            self.session.cookies.load()
예제 #23
0
    def __init__(
            self,
            hostname,
            username,
            password,
            fields=None,
            groups=None,
            selection=None,
            proxy=None):
        self.hostname = hostname

        # requests session
        self.session = requests.Session()

        self.auth = requests.auth.HTTPBasicAuth(username, password)
        # request headers
        self.headers = {
            "Accept": "application/json",
            "Content-Type": "application/json",
        }

        # request cookies
        self.cookies = LWPCookieJar(os.getenv("HOME") + "/.sn_api_session")
        try:
            self.cookies.load(ignore_discard=True)
        except IOError:
            pass
        self.session.cookies = self.cookies

        if fields is None:
            fields = []

        if groups is None:
            groups = []

        if selection is None:
            selection = []

        if proxy is None:
            proxy = []

        # extra fields (table columns)
        self.fields = fields

        # extra groups (table columns)
        self.groups = groups

        # selection order
        self.selection = selection

        # proxy settings
        self.proxy = proxy

        # initialize inventory
        self.inventory = {'_meta': {'hostvars': {}}}

        return
예제 #24
0
    def save_cookies(self, cookie_storage):
        """Save to cookielib's CookieJar or Set-Cookie3 format text file.

        :param cookie_storage: file location string or CookieJar instance.
        """
        def toPyCookieJar(QtCookieJar, PyCookieJar):
            for c in QtCookieJar.allCookies():
                PyCookieJar.set_cookie(toPyCookie(c))

        def toPyCookie(QtCookie):
            port = None
            port_specified = False
            secure = QtCookie.isSecure()
            name = str(QtCookie.name())
            value = str(QtCookie.value())
            v = str(QtCookie.path())
            path_specified = bool(v != "")
            path = v if path_specified else None
            v = str(QtCookie.domain())
            domain_specified = bool(v != "")
            domain = v
            if domain_specified:
                domain_initial_dot = v.startswith('.')
            else:
                domain_initial_dot = None
            v = long(QtCookie.expirationDate().toTime_t())
            # Long type boundary on 32bit platfroms; avoid ValueError
            expires = 2147483647 if v > 2147483647 else v
            rest = {}
            discard = False
            return Cookie(
                0,
                name,
                value,
                port,
                port_specified,
                domain,
                domain_specified,
                domain_initial_dot,
                path,
                path_specified,
                secure,
                expires,
                discard,
                None,
                None,
                rest,
            )

        if cookie_storage.__class__.__name__ == 'str':
            cj = LWPCookieJar(cookie_storage)
            toPyCookieJar(self.cookie_jar, cj)
            cj.save()
        elif cookie_storage.__class__.__name__.endswith('CookieJar'):
            toPyCookieJar(self.cookie_jar, cookie_storage)
        else:
            raise ValueError('unsupported cookie_storage type.')
예제 #25
0
def load_cookies4():
    """ 加载 cookie:cookies.txt -> load()  —— LWPCookieJar格式
    """
    cj = LWPCookieJar()
    cj.load('localCookiesLWP.txt', ignore_discard=True,
            ignore_expires=True)  # 这里必须将参数置为True,否则登录失败
    for index, cookie in enumerate(cj):  # 显示cookies
        print('[', index, ']', cookie)
    return cj
예제 #26
0
 def cookies(self):
     try:
         with open('cookies.txt'):
             pass
     except (OSError, IOError):
         cookies = LWPCookieJar('cookies.txt')
         cookies.save()
         return False
     return True
예제 #27
0
def auth():
    tmp = requests.utils.dict_from_cookiejar(user.cookies)
    session = requests.Session()
    cookie = LWPCookieJar()
    cookie.load(filename=COOKIE_FILENAME)
    print type(cookie), cookie
    session.cookies = cookie
    s = session.post('https://www.leetcode.com/dream_going')
    print s.status_code
    def __init__(self):
        self.logindata = {}
        self.username = ''
        self.password = ''

        #在http交互中即时更新cookie
        self.cookiejar = LWPCookieJar()
        cookiesupport = urllib2.HTTPCookieProcessor(self.cookiejar)
        opener = urllib2.build_opener(cookiesupport, urllib2.HTTPHandler)
        urllib2.install_opener(opener)
예제 #29
0
    def __init__(self, cookie_file=None):
        self.cookie_file = cookie_file
        self.s = requests.Session()
        self.s.cookies = LWPCookieJar(self.cookie_file)
        if fileExists(self.cookie_file):
            self.s.cookies.load(ignore_discard=True)
        self.s.headers.update({'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'})
        self.s.headers.update({'Accept-Language' : 'en-US,en;q=0.5'})

        self.url = ''
예제 #30
0
 def _loadCookies(self):
     self.session.cookies = LWPCookieJar('cookiejar')
     if not os.path.exists('cookiejar'):
         # Create a new cookies file and set our Session's cookies
         #print('setting cookies')
         self.session.cookies.save()
     else:
         # Load saved cookies from the file and use them in a request
         #print('loading saved cookies')
         self.session.cookies.load(ignore_discard=True)