Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def start_requests(self):
     #NOTE: (zacky, 2015.MAY.19th) WE MAYNOT NEED TO SET COOKIE.
     headers   = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0',
                  'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',}
     post_data = {'custom':'0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17',
                  'status':'1',}
     for date in get_date_list(from_date=self.from_date, to_date=self.to_date, delimiter='-'):
         post_data['startTime'] = post_data['endTime'] = date
         yield scrapy.FormRequest(self.start_formated_url.format(timestamp=date), method='POST', headers=headers, formdata=post_data)
Ejemplo n.º 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)

            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)