Example #1
0
 def start_requests(self):
     if self.login_url:
         timestamp = get_unix_time()
         signature = get_login_signature(self.username, self.password,
                                         timestamp, self.secret_key,
                                         self.is_upper)
         if self.secret_key:
             body = {
                 'username': self.username,
                 'password': self.password,
                 'timestamp': timestamp,
                 'signature': signature.upper()
             }
         else:
             body = {
                 'username': self.username,
                 'timestamp': timestamp,
                 'signature': signature
             }
         if self.is_json:
             yield Request(self.login_url,
                           body=json.dumps(body),
                           method='POST')
         else:
             yield scrapy.FormRequest(self.login_url, formdata=body)
Example #2
0
    def start_requests(self):
        if self.login_url:
            timestamp = get_unix_time()
            signature = get_login_signature(self.username, self.password, timestamp, self.secret_key)
            if self.secret_key:
                body = {'username':self.username, 'password':self.password, 'timestamp':timestamp, 'signature':signature.upper()}
            else:
                body = {'username':self.username, 'timestamp':timestamp, 'signature':signature}

            yield scrapy.FormRequest(self.login_url, formdata=body)
Example #3
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token') + '.tk')

            if self.need_token and lines: token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password,
                                             self.is_upper)

            body = {
                'token': token,
                'timestamp': timestamp,
                'signature': signature,
                'from_date': self.from_date,
                'to_date': self.to_date,
                'page_size': self.page_size,
                'page_index': self.page_index
            }
            if self.is_json:
                yield Request(self.start_formated_url,
                              body=json.dumps(body),
                              method='POST')
            else:
                yield scrapy.FormRequest(self.start_formated_url,
                                         formdata=body,
                                         dont_filter=True)
        else:
            if self.method:
                yield scrapy.FormRequest(
                    self.start_formated_url +
                    self.formated_parameters.format(page_size=self.page_size,
                                                    page_index=self.page_index,
                                                    from_date=self.from_date,
                                                    to_date=self.to_date),
                    method='GET',
                    dont_filter=True)
            else:
                body = {
                    'from_date': self.from_date,
                    'to_date': self.to_date,
                    'page_size': self.page_size,
                    'page_index': self.page_index
                }
                if self.is_json:
                    yield Request(self.start_formated_url,
                                  body=json.dumps(body),
                                  method='POST')
                else:
                    yield scrapy.FormRequest(self.start_formated_url,
                                             formdata=body,
                                             dont_filter=True)
Example #4
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token') + '.tk')

            if self.need_token and lines: token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password,
                                             self.is_upper)

            for date in get_date_list(from_date=self.from_date,
                                      to_date=self.to_date,
                                      delimiter='-'):
                body = {
                    'token': token,
                    'timestamp': timestamp,
                    'signature': signature,
                    'date': date
                }
                if self.is_json:
                    yield Request(self.start_formated_url,
                                  body=json.dumps(body),
                                  method='POST')
                else:
                    yield scrapy.FormRequest(self.start_formated_url,
                                             formdata=body,
                                             dont_filter=True)
        else:
            if self.method:
                for date in get_date_list(from_date=self.from_date,
                                          to_date=self.to_date,
                                          delimiter='-'):
                    yield scrapy.FormRequest(
                        self.start_formated_url.format(date=date),
                        method='GET',
                        dont_filter=True)
            else:
                for date in get_date_list(from_date=self.from_date,
                                          to_date=self.to_date,
                                          delimiter='-'):
                    body = {'date': date}
                    if self.is_json:
                        yield Request(self.start_formated_url,
                                      body=json.dumps(body),
                                      method='POST')
                    else:
                        yield scrapy.FormRequest(self.start_formated_url,
                                                 formdata=body,
                                                 dont_filter=True)
Example #5
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token')+'.tk')
            if self.need_token and lines:
                token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password)
            body = {'token': token, 'timestamp': timestamp, 'signature': signature, 'month': self.month}

            yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
        else:
            if self.method:
                yield scrapy.FormRequest(self.start_formated_url.format(month=self.month), method='GET', dont_filter=True)
            else:
                body = {'month':self.month}
                yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
Example #6
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token')+'.tk')

            if self.need_token and lines: token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password)

            body = {'token': token, 'timestamp': timestamp, 'signature': signature, 'from_date': self.from_date, 'to_date': self.to_date, 'page_size': self.page_size, 'page_index': self.page_index}

            yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
        else:
            if self.method:
                yield scrapy.FormRequest(self.start_formated_url+self.formated_parameters.format(page_size=self.page_size, page_index=self.page_index, from_date=self.from_date, to_date=self.to_date), method='GET', dont_filter=True)
            else:
                body = {'from_date': self.from_date,'to_date': self.to_date, 'page_size': self.page_size, 'page_index': self.page_index}
                yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
Example #7
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token')+'.tk')

            if self.need_token and lines: token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password)

            for date in get_date_list(from_date=self.from_date, to_date=self.to_date, delimiter='-'):
                body = {'token': token, 'timestamp': timestamp, 'signature': signature, 'date': date}
                yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
        else:
            if self.method:
                for date in get_date_list(from_date=self.from_date, to_date=self.to_date, delimiter='-'):
                    yield scrapy.FormRequest(self.start_formated_url.format(date=date), method='GET', dont_filter=True)
            else:
                for date in get_date_list(from_date=self.from_date, to_date=self.to_date, delimiter='-'):
                    body = {'date': date}
                    yield scrapy.FormRequest(self.start_formated_url, formdata=body, dont_filter=True)
Example #8
0
    def start_requests(self):
        if self.need_token:
            token = ''
            lines = read_cache('tokens', (self.plat_id or 'token') + '.tk')
            if self.need_token and lines:
                token = lines[0]

            timestamp = get_unix_time()
            signature = get_access_signature(token, timestamp, self.password,
                                             self.is_upper)
            body = {
                'token': token,
                'timestamp': timestamp,
                'signature': signature,
                'month': self.month
            }
            if self.is_json:
                yield Request(self.start_formated_url,
                              body=json.dumps(body),
                              method='POST')
            else:
                yield scrapy.FormRequest(self.start_formated_url,
                                         formdata=body,
                                         dont_filter=True)
        else:
            if self.method:
                yield scrapy.FormRequest(
                    self.start_formated_url.format(month=self.month),
                    method='GET',
                    dont_filter=True)
            else:
                body = {'month': self.month}
                if self.is_json:
                    yield Request(self.start_formated_url,
                                  body=json.dumps(body),
                                  method='POST')
                else:
                    yield scrapy.FormRequest(self.start_formated_url,
                                             formdata=body,
                                             dont_filter=True)