Exemplo n.º 1
0
 def SubTask(self, driver, TaskInfo):
     SelectCard = self.PopCard()
     if SelectCard:
         TaskInfo.update(SelectCard)
         Task = AmazonFunction(driver, TaskInfo)
         if not Task.login():
             self.PushCard(SelectCard)
             print('Login fail...')
             return False
         if Task.AddCreditCard():
             print('Credit Card added for: ' + TaskInfo['username'])
         else:
             self.PushCard(SelectCard)
             print('Credit Card add fail for: ' + TaskInfo['username'])
     else:
         TaskInfo.update({
             'nameoncard': '',
             'ccnumber': '',
             'ccmonth': '',
             'ccyear': '',
             'cardstatus': '',
             'checkaccount': ''
         })
         TaskInfo['status'] = False
         TaskInfo['errorcode'] = 'InsufficientCard'
         print('Credit Card is insufficient for: ' + TaskInfo['username'])
     time.sleep(5)
     Task.FunctionInfo['cookies'] = json.dumps(driver.get_cookies())
Exemplo n.º 2
0
 def updateprice(self, TaskSummury, retrycnt=3):
     while True:
         print('Begin to update price...')
         for item in TaskSummury:
             for i in range(retrycnt):
                 try:
                     proxy = self.GetProxy()
                     driver = self.WebDriver(proxy)
                     print('Update price for ' + item['asin'])
                     production_url = AmazonTables.URLDomains(
                         item['country']) + 'gp/product/' + item['asin']
                     TASK = AmazonFunction(driver, FunctionInfo=item)
                     price = TASK.check_price(production_url)
                     driver.delete_all_cookies()
                     driver.quit()
                 except:
                     print(traceback.print_exc())
                     time.sleep(30)
                     continue
                 if price:
                     item.update(price)
                     break
                 else:
                     print('Price update for ' + item['asin'] + ' failed!')
         time.sleep(30)
         print('Update price done...')
         time.sleep(7200)
Exemplo n.º 3
0
 def SubTask(self, driver, TaskInfo):
     SelectAddress = self.PopAddress()
     if SelectAddress:
         TaskInfo.update(SelectAddress)
         Task = AmazonFunction(driver, TaskInfo)
         if not Task.login():
             self.PushAddress(SelectAddress)
             print('Login fail...')
             return False
         if Task.SetAddress():
             print('Shipping address added for: ' + TaskInfo['username'])
         else:
             self.PushAddress(SelectAddress)
             print('Shipping address add fail for: ' + TaskInfo['username'])
     else:
         TaskInfo.update({
             'fullname': '',
             'address': '',
             'postalcode': '',
             'city': '',
             'state': '',
             'phonenumber': '',
             'addressstatus': ''
         })
         TaskInfo['status'] = False
         TaskInfo['errorcode'] = 'InsufficientAddress'
         print('Address is insufficient for: ' + TaskInfo['username'])
     time.sleep(5)
Exemplo n.º 4
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(5)
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     Task.NewRandomAccount = False
     Task.speed = randint(50, 100)
     EmailDomain = '@foxairmail.com'
     if not Task.login():
         return False
     time.sleep(5)
     Task.FunctionInfo.update(TaskInfo['billingaddress'])
     Viewpages = AmazonPages(driver)
     for i in range(randint(2, 6)):
         Viewpages.RandomClick()
         Viewpages.WalkAround(ScrollSpeed=[5, 20])
         time.sleep(randint(5, 15))
     TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     TaskInfo['logindate'] = datetime()
     db = amazon_db()
     db.open()
     db.accountinfo_update_item(
         TaskInfo['username'],
         TaskInfo['password'],
         TaskInfo['cookies'],
         TaskInfo['createdate'],
         TaskInfo['logindate'],
         TaskInfo['lastbuy'],
         TaskInfo['in_use'],
         TaskInfo['alive'],
         TaskInfo['MAC'],
     )
     db.close()
     del db
     return True
Exemplo n.º 5
0
 def SubTask(self, driver, TaskInfo):
     Task = AmazonFunction(driver, TaskInfo)
     Task.VerifyEnhance = True
     if Task.login():
         try:
             driver.get("https://www.amazon.com/")
             time.sleep(5)
         except:
             pass
         if self.WalkaroundEn:
             Task.Walkaround()
         TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     else:
         TaskInfo['cookies'] = ''
     pass
Exemplo n.º 6
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(5)
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     Task.NewRandomAccount = False
     Task.speed = randint(50, 100)
     EmailDomain = '@foxairmail.com'
     if not Task.CreatAcount(EmailDomain):
         return False
     time.sleep(5)
     Task.FunctionInfo.update(TaskInfo['billingaddress'])
     SubRetry = 0
     while not Task.AddCreditCard():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             print('Credit Card add fail for: ' + TaskInfo['username'])
             return False
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     SubRetry = 0
     while not Task.SetAddress():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             print(traceback.print_exc())
             return False
     Viewpages = AmazonPages(driver)
     for i in range(randint(2,6)):
         Viewpages.RandomClick()
         Viewpages.WalkAround(ScrollSpeed=[5,20])
         time.sleep(randint(5,15))
     TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     return True
Exemplo n.º 7
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(5)
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     Task.NewRandomAccount = False
     Task.speed = randint(50, 100)
     EmailDomain = '@foxairmail.com'
     if not Task.login():
         return False
     time.sleep(5)
     Task.FunctionInfo.update(TaskInfo['billingaddress'])
     Viewpages = AmazonPages(driver)
     for i in range(randint(2, 6)):
         Viewpages.RandomClick()
         Viewpages.WalkAround(ScrollSpeed=[5, 20])
         time.sleep(randint(5, 15))
     TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     return True
Exemplo n.º 8
0
 def SubTask(self, driver, TaskInfo):
     TaskInfo['asin'] = ''
     TaskInfo['reviewerid'] = ''
     TaskInfo['reviewstar'] = ''
     TaskInfo['reviewertitle'] = ''
     TaskInfo['reviewercontent'] = ''
     TaskInfo['reviewerusername'] = TaskInfo['username']
     Task = AmazonFunction(driver, TaskInfo)
     if not Task.login():
         self.PushRetryQueue(TaskInfo)
         self.TaskLog(TaskInfo)
         return False
     if not Task.GoToReview():
         self.PushRetryQueue(TaskInfo)
         self.TaskLog(TaskInfo)
         return False
     TaskInfoCopy = TaskInfo['asins'].copy()
     for asin in TaskInfoCopy:
         TaskInfo.update({'asin': asin})
         SelectReviewer = self.PopReviewer(asin)
         TaskInfo.update(SelectReviewer)
         if SelectReviewer['reviewercontent']:
             if Task.WriteReview():
                 print('Reviewer added for: ' + TaskInfo['username'] +
                       ' :: ' + asin)
                 TaskInfo['asins'].remove(asin)
             else:
                 self.PushReviewer(SelectReviewer)
                 print('Reviewer fail for: ' + TaskInfo['username'] +
                       ' :: ' + asin)
         else:
             TaskInfo['status'] = False
             TaskInfo['errorcode'] = 'InsufficientReviewer'
             print('Reviewer is insufficient for: ' + TaskInfo['username'] +
                   ' :: ' + asin)
             TaskInfo['asins'].remove(asin)
         self.TaskLog(TaskInfo)
     # not all ASIN done
     if TaskInfo['asins']:
         self.PushRetryQueue(TaskInfo)
     pass
Exemplo n.º 9
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(5)
     TaskInfo['Logout'] = True
     TaskInfo['cookies'] = AccountFrame.loc[TaskInfo['username']]['cookies']
     while TaskInfo['username'] in self.submitedUser:
         time.sleep(30)
         print('Reviewer waits for: ' + TaskInfo['username'] + ' :: ' +
               TaskInfo['asin'])
     print('Reviewer begins for: ' + TaskInfo['username'] + ' :: ' +
           TaskInfo['asin'])
     self.submitedUser.append(TaskInfo['username'])
     Task = AmazonFunction(driver, TaskInfo)
     if not Task.login():
         self.TaskLog(TaskInfo)
         return False
     if not Task.GoToReview():
         self.TaskLog(TaskInfo)
         return False
     if Task.WriteReview():
         print('Reviewer added for: ' + TaskInfo['username'] + ' :: ' +
               TaskInfo['asin'])
     else:
         print('Reviewer fail for: ' + TaskInfo['username'] + ' :: ' +
               TaskInfo['asin'])
Exemplo n.º 10
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(10)
     TaskInfo['Logout'] = True
     if TaskInfo['username'] in self.submitedUser:
         TaskInfo['Logout'] = False
         while TaskInfo['username'] in self.submitedUser:
             time.sleep(30)
             print('Reviewer waits for: ' + TaskInfo['username'] + ' :: ' + TaskInfo['asin'])
             TaskInfo['status'] = False
             TaskInfo['errorcode'] = 'WaitToLogin'
         TaskInfo['retrynumber'] -= 1
         return
     print('Reviewer begins for: ' + TaskInfo['username'] + ' :: ' + TaskInfo['asin'])
     self.submitedUser.append(TaskInfo['username'])
     Task = AmazonFunction(driver, TaskInfo)
     if not Task.login():
         return False
     TaskInfo['cookies'] = json.dumps(driver.get_cookies())
     if not Task.GoToReview():
         return False
     if Task.WriteReview():
         print('Reviewer added for: ' + TaskInfo['username'] + ' :: ' + TaskInfo['asin'])
     else:
         print('Reviewer fail for: ' + TaskInfo['username'] + ' :: ' + TaskInfo['asin'])
Exemplo n.º 11
0
 def SubTask(self, driver, TaskInfo):
     TaskInfo['newcookies'] = ''
     TaskInfo['newemail'] = ''
     TaskInfo['newepassword'] = ''
     Task = AmazonFunction(driver, TaskInfo)
     if not Task.login():
         print('Login fail...')
         return False
     if not Task.SecurityPage():
         return False
     EmailDomain = '@foxairmail.com'
     if not Task.ChangeEmail(EmailDomain):
         return False
     if not Task.ChangePassword():
         return False
     #TaskInfo['newemail'] = TaskInfo['username']
     TaskInfo['newcookies'] = json.dumps(driver.get_cookies())
Exemplo n.º 12
0
 def SubTask(self, driver, TaskInfo):
     driver.get("https://www.amazon.com/")
     time.sleep(10)
     Task = AmazonFunction(driver, TaskInfo)
     Task.speed = randint(120, 160)
     Task.FunctionInfo['lowprice'] = str(
         round((float(Task.FunctionInfo['buyboxprice']) - 0.01), 2))
     Task.FunctionInfo['highprice'] = str(
         round((float(Task.FunctionInfo['buyboxprice']) + 0.01), 2))
     SearchTask = AmazonPages(driver)
     #if not Task.SearchProduct():
     if not SearchTask.SearchAndView(TaskInfo):
         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...')
         return False
     return True
Exemplo n.º 13
0
 def SubTask(self, driver, TaskInfo):
     TaskInfo['username'] = ''
     TaskInfo['password'] = ''
     TaskInfo['cookies'] = ''
     Task = AmazonFunction(driver, TaskInfo)
     EmailDomain = '@foxairmail.com'
     if not Task.CreatAcount(EmailDomain):
         return False
     Task.driver.get("https://www.amazon.com/")
     try:
         Task.driver.find_element_by_id('nav-logo').click()
     except:
         pass
     try:
         Task.ViewAllPage()
         Task.Walkaround()
     except:
         pass
     Task.FunctionInfo['cookies'] = json.dumps(driver.get_cookies())
     #Task.FunctionInfo['cookies'] = ''
     return True
Exemplo n.º 14
0
 def SubTask(self, driver, TaskInfo):
     driver.implicitly_wait(5)
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     Task.NewRandomAccount = False
     Task.speed = randint(50, 100)
     EmailDomain = '@foxairmail.com'
     if not Task.CreatAcount(EmailDomain):
         return False
     time.sleep(5)
     Task.FunctionInfo.update(TaskInfo['billingaddress'])
     SubRetry = 0
     while not Task.AddCreditCard():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             print('Credit Card add fail for: ' + TaskInfo['username'])
             return False
     Task.FunctionInfo.update(TaskInfo['shippingaddress'])
     SubRetry = 0
     while not Task.SetAddress():
         SubRetry += 1
         if SubRetry > self.SubMaxRetry:
             print(traceback.print_exc())
             return False
     SearchTask = AmazonPages(driver)
     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.03), 2))
         Task.FunctionInfo['highprice'] = str(
             round((float(Task.FunctionInfo['buyboxprice']) + 0.02), 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
Exemplo n.º 15
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
Exemplo n.º 16
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
Exemplo n.º 17
0
 def SubTask(self, driver, TaskInfo):
     Task = AmazonFunction(driver, TaskInfo)
     TaskInfo['ordernumber'] = ''
     if not Task.login():
         return False
     Task.PlaceOrder()
Exemplo n.º 18
0
    def SubTask(self, driver, TaskInfo):
        TaskInfo['lowprice'] = '0'
        TaskInfo['highprice'] = '0'
        self.TaskName = TaskInfo['asin']
        self.start_time = datetime.now()
        TaskInfo['keyword'] = random.sample(TaskInfo['keywords'], 1)[0]
        print('start info:::' + TaskInfo['asin'] + ' keyword: ' +
              TaskInfo['keyword'])
        Task = AmazonFunction(driver, TaskInfo)

        try:
            Task.driver.get('https://www.amazon.com/')
        except:
            pass
        try:
            Task.driver.maximize_window()
        except:
            print('Set full screen fail!')

        ProductionUrl = Task.SearchProduct()
        if not ProductionUrl:
            return False
        if not Task.ViewAllPage():
            return False
        if not Task.view_reviewer():
            return False
        if not Task.add_to_cart():
            return False
        Task.back_to_page(ProductionUrl)

        while Task.stay_time() < Task.min_view_time:
            Task.speed = randint(20, 60)
            if not Task.view_all():
                return False
            Task.back_to_page(ProductionUrl)

        self.TaskLog(TaskInfo)
        if int(TaskInfo['sections']) != '0':
            self.PushRetryQueue(TaskInfo)
            TaskInfo['sections'] = str(int(TaskInfo['sections']) - 1)