示例#1
0
 def __init__(self):
     if helper.has_file_path('phimbathu.bin') and helper.get_last_modified_time_file('phimbathu.bin') + 43200 > \
             int(time.time()):
         with open(helper.get_file_path('phimbathu.bin')) as f:
             self.cookies = pickle.load(f)
     else:
         self.updateSession(self.domain)
     self.request = Request()
示例#2
0
 def updateSession(self, url, delay=10):
     try:
         scraper = CloudScraper.create_scraper(delay=delay)
         scraper.headers.update({'User-Agent': user_agent})
         self.cookies = scraper.get(url).cookies.get_dict()
         with open(helper.get_file_path('phimmedia.bin'), 'wb') as f:
             pickle.dump(self.cookies, f)
     except:
         pass
示例#3
0
    def updateSession(self, url, delay=10):
        scraper = CloudScraper.create_scraper(delay=delay)
        scraper.headers.update({'User-Agent': user_agent})
        self.cookies = scraper.get(url).cookies.get_dict()
        if not helper.has_file_path('phimbathu.bin'):
            helper.write_file('phimbathu.bin', '')

        with open(helper.get_file_path('phimbathu.bin'), 'wb+') as f:
            pickle.dump(self.cookies, f)
示例#4
0
 def __init__(self):
     self.request = Request(session=True)
     if helper.has_file_path('xomphimhay.bin'):
         with open(helper.get_file_path('xomphimhay.bin')) as f:
             self.request.set_session(pickle.load(f))
         cookies_jar = self.request.get_request_session().cookies
         cookies_jar.set('vietnamese',
                         'true',
                         domain='xomphimhay.com',
                         path='/')
         print cookies_jar
示例#5
0
    def __init__(self):
        self.request = Request(session=True)
        if helper.has_file_path(
                'xomphimhay.bin') and helper.get_last_modified_time_file(
                    'xomphimhay.bin') + 43200 < int(time.time()):
            helper.remove_file('xomphimhay.bin')

        if helper.has_file_path('xomphimhay.bin'):
            with open(helper.get_file_path('xomphimhay.bin')) as f:
                self.request.set_session(pickle.load(f))
            cookies_jar = self.request.get_request_session().cookies
            cookies_jar.set('vietnamese',
                            'true',
                            domain='xomphimhay.com',
                            path='/')
示例#6
0
    def __init__(self, url, username="", password=""):
        self.token = None
        self.url = url
        self.username = username
        self.password = password
        self.request = Request(session=True)
        if helper.has_file_path(
                'fshare.bin'
        ) and helper.get_last_modified_time_file('fshare.bin') + 43200 < int(
                time.time()):
            helper.remove_file('fshare.bin')

        if helper.has_file_path('fshare.bin'):
            with open(helper.get_file_path('fshare.bin')) as f:
                cache = pickle.load(f)
                self.request.get_request_session().cookies.set(
                    'session_id', cache.get('session_id'))
示例#7
0
    def login(self, token=""):
        url = 'https://api.fshare.vn/api/user/login'
        r = self.request.post(url,
                              json={
                                  'user_email':
                                  self.username,
                                  'password':
                                  self.password,
                                  'app_key':
                                  'L2S7R6ZMagggC5wWkQhX2+aDi467PPuftWUMRFSn'
                              })

        r = json.loads(r)
        if r.get('code') == 200:
            with open(helper.get_file_path('fshare.bin'), 'wb+') as f:
                pickle.dump(r, f)
        else:
            helper.remove_file('fshare.bin')
            raise Exception('Fshare', 'Login error')

        return r
示例#8
0
 def updateSession(self):
     with open(helper.get_file_path('motphim.bin'), 'wb') as f:
         pickle.dump(self.request.get_request_session(), f)
示例#9
0
    def updateSession(self):
        if not helper.has_file_path('xomphimhay.bin'):
            helper.write_file('xomphimhay.bin', '')

        with open(helper.get_file_path('xomphimhay.bin'), 'wb+') as f:
            pickle.dump(self.request.get_request_session(), f)
示例#10
0
 def updateSession(self):
     with open(helper.get_file_path('xomphimhay.bin'), 'wb') as f:
         print self.request.get_request_session()
         pickle.dump(self.request.get_request_session(), f)