Esempio n. 1
0
    def SubTask(self, driver, TaskInfo):
        Task = AmazonFunction(driver, TaskInfo)
        Task.speed = randint(100, 160)
        if not Task.login():
            return False
        time.sleep(5)
        if not Task.CleanCart():
            return False
        if not Task.SetAddress():
            return False

        for asin in TaskInfo['asins']:
            Task.FunctionInfo['asin'] = asin
            Task.FunctionInfo.update(parseinfo.ProductFrame.loc[
                Task.FunctionInfo['asin']].to_dict())
            Task.FunctionInfo['lowprice'] = str(
                round((float(Task.FunctionInfo['buyboxprice']) - 0.01), 2))
            Task.FunctionInfo['highprice'] = str(
                round((float(Task.FunctionInfo['buyboxprice']) + 0.01), 2))
            #Task.FunctionInfo['lowprice'] = Task.FunctionInfo['buyboxprice']
            #Task.FunctionInfo['highprice'] = Task.FunctionInfo['buyboxprice']
            if not Task.SearchProduct():
                print('Search production fail...')
                # Fatal error if not found in any page  TBD
                TaskInfo['errorcode'] = 'SearchFail'
                TaskInfo['status'] = False
                return False
            if not Task.AddCart():
                print('Add cart fail...')
                # Fatal error if not found TBD
                return False
        return True
Esempio n. 2
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(10)
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     Task.speed = randint(80, 160)
     if not Task.login():
         return False
     time.sleep(5)
     if TaskInfo['retrynumber'] == 0:
         SubRetry = 0
         while not Task.CleanCart():
             SubRetry += 1
             if SubRetry > self.SubMaxRetry:
                 return False
     SubRetry = 0
     while not Task.SetAddress():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             return False
     SearchTask = AmazonPages(driver)
     SearchTask.SortOutTask(TaskInfo)
     for asin in TaskInfo['asins']:
         Task.FunctionInfo['asin'] = asin
         Task.FunctionInfo.update(
             ProductFrame.loc[Task.FunctionInfo['asin']].to_dict())
         Task.FunctionInfo['lowprice'] = str(
             round((float(Task.FunctionInfo['buyboxprice']) - 0.05), 2))
         Task.FunctionInfo['highprice'] = str(
             round((float(Task.FunctionInfo['buyboxprice']) + 0.05), 2))
         #Task.FunctionInfo['lowprice'] = Task.FunctionInfo['buyboxprice']
         #Task.FunctionInfo['highprice'] = Task.FunctionInfo['buyboxprice']
         SubRetry = 0
         while not SearchTask.SearchAndView(TaskInfo):
             SubRetry += 1
             if SubRetry > self.SubMaxRetry:
                 print('Search production fail...')
                 # Fatal error if not found in any page  TBD
                 TaskInfo['errorcode'] = 'SearchFail'
                 TaskInfo['status'] = False
                 return False
         SubRetry = 0
         while not Task.AddCart():
             SubRetry += 1
             if SubRetry > self.SubMaxRetry:
                 print('Add cart fail...')
                 # Fatal error if not found TBD
                 return False
     SubRetry = 0
     while not Task.PlaceOrder():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             return False
     TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     return True