def run(self):
        # Disable Sikuli action and info log
        com = common.General()
        com.infolog_enable(False)
        com.set_mouse_delay(0)

        # Prepare
        app = amazon.Amazon()
        sample1_file_path = os.path.join(self.INPUT_IMG_SAMPLE_DIR_PATH,
                                         self.INPUT_IMG_OUTPUT_SAMPLE_1_NAME)
        sample1_file_path = sample1_file_path.replace(
            os.path.splitext(sample1_file_path)[1], '.png')
        capture_width = int(self.INPUT_RECORD_WIDTH)
        capture_height = int(self.INPUT_RECORD_HEIGHT)

        # Launch browser
        my_browser = browser.Chrome()

        # Access link and wait
        my_browser.clickBar()
        my_browser.enterLink(self.INPUT_TEST_TARGET)
        app.wait_for_logo_loaded()

        # Wait for stable
        sleep(2)

        # PRE ACTIONS
        type(Key.PAGE_DOWN)
        sleep(2)

        # Customized Region
        customized_region_name = 'end'

        _, obj = app.wait_for_customer_text_loaded()
        # product thumbnail list region
        compare_area = Region(obj.x, obj.y, obj.w + 850, obj.h + 250)
        self.set_override_region_settings(customized_region_name, compare_area)
        sleep(2)

        # Record T1, and capture the snapshot image
        # Input Latency Action
        screenshot, t1 = app.il_hover_fifth_customer_watched_product(
            capture_width, capture_height)

        # In normal condition, a should appear within 100ms,
        # but if lag happened, that could lead the show up after 100 ms,
        # and that will cause the calculation of AIL much smaller than expected.
        sleep(0.1)

        # Record T2
        t2 = time.time()

        # POST ACTIONS
        sleep(1)

        # Write timestamp
        com.updateJson({'t1': t1, 't2': t2}, self.INPUT_TIMESTAMP_FILE_PATH)

        # Write the snapshot image
        shutil.move(screenshot, sample1_file_path)
예제 #2
0
 def __init__(self, filename = None):
     row = 1
     amazon_data = amazon.Amazon()
     for item in amazon_data:
         print 'Amazon Data-- Begin'
         print item
         print 'Amazon Data-- End'
         ws.write(row, ws_col_ASIN, item[0])
         ws.write(row, ws_col_UPC, item[1])
         ws.write(row, ws_col_Brand, item[2])
         ws.write(row, ws_col_MPN, item[3])
         ws.write(row, ws_col_Title, item[4])
         ws.write(row, ws_col_Quantity, None)
         ws.write(row, ws_col_MSRP, None)
         ws.write(row, ws_col_E_MSRP, None)
         ws.write(row, ws_col_Length, item[5])
         ws.write(row, ws_col_Width, item[6])
         ws.write(row, ws_col_Heigth, item[7])
         ws.write(row, ws_col_Weigth, item[8])
         ws.write(row, ws_col_amazon_sales_rank, item[9])
         ws.write(row, ws_col_amazon_price, item[10])
         ebay_data = ebay.ebayAPI().search([item[1], item[3], item[4]])
         ws.write(row, ws_col_act, ebay_data[0])
         ws.write(row, ws_col_act_avg, ebay_data[1])
         ws.write(row, ws_col_sold, ebay_data[2])
         ws.write(row, ws_col_sold_avg, ebay_data[3])
         ws.write(row, ws_col_trending_price, ebay_data[4])
         ws.write(row, ws_col_trending_price_new, ebay_data[5])
         ws.write(row, ws_col_trending_price_new_other, ebay_data[6])
         ws.write(row, ws_col_trending_price_used, ebay_data[7])
         ws.write(row, ws_col_trending_price_for_parts, ebay_data[8])
         row += 1
     wb.close()
    def run(self):
        # Disable Sikuli action and info log
        com = common.General()
        com.infolog_enable(False)
        com.set_mouse_delay(0)

        # Prepare
        app = amazon.Amazon()
        sample1_file_path = os.path.join(self.INPUT_IMG_SAMPLE_DIR_PATH, self.INPUT_IMG_OUTPUT_SAMPLE_1_NAME)
        sample1_file_path = sample1_file_path.replace(os.path.splitext(sample1_file_path)[1], '.png')
        capture_width = int(self.INPUT_RECORD_WIDTH)
        capture_height = int(self.INPUT_RECORD_HEIGHT)

        # Launch browser
        my_browser = browser.Firefox()

        # Access link and wait
        my_browser.clickBar()
        my_browser.enterLink(self.INPUT_TEST_TARGET)
        app.wait_for_search_button_loaded()

        # Wait for stable
        sleep(2)

        # PRE ACTIONS
        app.click_search_field()
        sleep(1)

        # Customized Region
        customized_region_name = 'end'
        type_area = wait(Pattern('search_bar.png').similar(0.90), 10)
        self.set_override_region_settings(customized_region_name, type_area)
        sleep(2)

        # Record T1, and capture the snapshot image
        # Input Latency Action
        screenshot, t1 = app.il_type('m', capture_width, capture_height)

        # In normal condition, a should appear within 100ms,
        # but if lag happened, that could lead the show up after 100 ms,
        # and that will cause the calculation of AIL much smaller than expected.
        sleep(0.1)

        # Record T2
        t2 = time.time()

        # POST ACTIONS

        # Write timestamp
        com.updateJson({'t1': t1, 't2': t2}, self.INPUT_TIMESTAMP_FILE_PATH)

        # Write the snapshot image
        shutil.move(screenshot, sample1_file_path)
예제 #4
0
 def testAmazon(self, name):
     ob = am.Amazon()
     x = ob.callApi(name)
     print('Tested successfully')
     print(x)
     pr = x['price_of_the_product']
     listpr = pr.values.tolist()
     for i in listpr:
         self.price.append(i)
     nm = x['name_of_the_product']
     listnm = nm.values.tolist()
     for j in listnm:
         self.name_of_the_product.append(j)
     for i in range(0, len(listnm)):
         self.site.append("AMAZON")
     #print(x['price_of_the_product'])
     print('Done')
     print(self.name_of_the_product)
     print(self.price)
     print(self.site)
예제 #5
0
 def PostFromAmazon(self,
                    keywordsList,
                    actionsCount,
                    boardsList,
                    department='All'):
     '''Парсим амазон и постим на доску'''
     itemsList = []
     actionNum = 1
     failsCount = 0
     pageNum = 1
     '''Постим'''
     amazonObj = amazon.Amazon(self)
     while (actionNum <= actionsCount) and (failsCount <
                                            self.maxFailsCount):
         if len(itemsList) == 0:
             self._Print(
                 'Searching for Amazon items by keywords "%s" in "%s" ... '
                 % (','.join(keywordsList), department),
                 end='')
             itemsList = amazonObj.Parse(keywordsList, pageNum, department)
             self._Print('%d found' % len(itemsList))
             pageNum += 1
             if len(itemsList) == 0:
                 self._Print('Out of items')
                 break
         item = itemsList.pop(0)
         if item['id'] not in self.user.amazonPostedItemsList:
             board = self._FindOrCreateBoard(boardsList)
             if self._AddPin(board, item['title'], item['link'],
                             item['imageUrl'],
                             ' (%d/%d)' % (actionNum, actionsCount)):
                 self.user.amazonPostedItemsList.append(item['id'])
                 self.user.SaveData()
                 actionNum += 1
             else:
                 failsCount += 1
     if failsCount >= self.maxFailsCount:
         self._Print('Action cancelled, max fails count exceeded')
    def run(self):
        # Disable Sikuli action and info log
        com = common.General()
        com.infolog_enable(False)
        com.set_mouse_delay(0)
        delay = com.find_key_type_delay()

        # Prepare
        app = amazon.Amazon()
        sample1_file_path = os.path.join(self.INPUT_IMG_SAMPLE_DIR_PATH,
                                         self.INPUT_IMG_OUTPUT_SAMPLE_1_NAME)
        sample2_file_path = os.path.join(
            self.INPUT_IMG_SAMPLE_DIR_PATH,
            self.INPUT_IMG_OUTPUT_SAMPLE_1_NAME.replace(
                'sample_1', 'sample_2'))
        sample1_file_path = sample1_file_path.replace(
            os.path.splitext(sample1_file_path)[1], '.png')
        sample2_file_path = sample2_file_path.replace(
            os.path.splitext(sample2_file_path)[1], '.png')
        capture_width = int(self.INPUT_RECORD_WIDTH)
        capture_height = int(self.INPUT_RECORD_HEIGHT)

        # Launch browser
        my_browser = browser.Firefox()

        # Access link and wait
        my_browser.clickBar()
        my_browser.enterLink(self.INPUT_TEST_TARGET)
        app.wait_for_search_button_loaded()

        # Wait for stable
        sleep(2)

        # PRE ACTIONS
        app.click_search_field()
        sleep(1)

        # Customized Region
        customized_region_name_start = 'start'
        customized_region_name_end = 'end'
        _, type_area = app.wait_for_component_display(app.AMAZON_SEARCH_BAR,
                                                      similarity=0.9)
        self.set_override_region_settings(customized_region_name_start,
                                          type_area)
        self.set_override_region_settings(customized_region_name_end,
                                          type_area)

        t1 = time.time()
        capimg1 = capture(0, 0, capture_width, capture_height)

        # Reference from https://en.wikipedia.org/wiki/Lorem_ipsum
        # extract 100 chars from Lorem ipsum text and filter characters which will affect result, e.g., i, j, and l
        char_str = "orempsumdorstametconsecteturadpscngetsedoeusmodtemporncduntutaboretdoremagnaquatenmadmnvenamqusnoexe"
        com.system_print('Type char')
        com.delayed_type(char_str, 0.1, delay)
        sleep(1)

        # Record T2
        t2 = time.time()

        # POST ACTIONS
        capimg2 = capture(0, 0, capture_width, capture_height)

        # Write timestamp
        com.updateJson({'t1': t1, 't2': t2}, self.INPUT_TIMESTAMP_FILE_PATH)

        # Write the snapshot image
        shutil.move(capimg1, sample1_file_path)
        shutil.move(capimg2, sample2_file_path)
    def run(self):
        # Disable Sikuli action and info log
        com = common.General()
        com.infolog_enable(False)
        com.set_mouse_delay(0)

        # Prepare
        app = amazon.Amazon()
        sample1_file_path = os.path.join(self.INPUT_IMG_SAMPLE_DIR_PATH, self.INPUT_IMG_OUTPUT_SAMPLE_1_NAME)
        sample1_file_path = sample1_file_path.replace(os.path.splitext(sample1_file_path)[1], '.png')
        capture_width = int(self.INPUT_RECORD_WIDTH)
        capture_height = int(self.INPUT_RECORD_HEIGHT)

        # Launch browser
        my_browser = browser.Firefox()

        # Access link and wait
        my_browser.clickBar()
        my_browser.enterLink(self.INPUT_TEST_TARGET)
        _, obj = app.wait_for_logo_loaded()

        # Wait for stable
        sleep(2)

        # PRE ACTIONS
        app.click_search_field()

        # user function's related position from logo
        pattern = capture(obj.x + 160, obj.y + 50, obj.w + 100, obj.h)
        sleep(1)
        type('m')
        com.system_print('Wait temp pattern {} vanished.'.format(pattern))
        app.wait_pattern_for_vanished(pattern=pattern, similarity=0.9)
        com.loop_type_key(Key.DOWN, 2, 0.5)

        # Customized Region
        customized_region_name = 'end'

        # part region of search suggestion list
        compare_area = self.tuning_region(obj, x_offset=160, w_offset=200, h_offset=50)
        self.set_override_region_settings(customized_region_name, compare_area)
        sleep(2)

        # Record T1, and capture the snapshot image
        # Input Latency Action
        screenshot, t1 = app.il_type_key_down_search_suggestion(capture_width, capture_height)

        # In normal condition, a should appear within 100ms,
        # but if lag happened, that could lead the show up after 100 ms,
        # and that will cause the calculation of AIL much smaller than expected.
        sleep(0.1)

        # Record T2
        t2 = time.time()

        # POST ACTIONS
        sleep(1)

        # Write timestamp
        com.updateJson({'t1': t1, 't2': t2}, self.INPUT_TIMESTAMP_FILE_PATH)

        # Write the snapshot image
        shutil.move(screenshot, sample1_file_path)
예제 #8
0
# windows
driver = webdriver.Chrome(options=chrome_options,
                          executable_path='chromedriver.exe')

driver.get(
    'https://www.amazon.com/gp/browse.html?node=11851273011&ref_=ods_gw_tpr_sd21_d_h1_xpl_ddp&pf_rd_r=9MKAX6SAY9R2ZW47ZZCK&pf_rd_p=de877882-d27e-4efc-8560-da3c0f2a82bf'
)

deal_title_elems = driver.find_elements_by_css_selector('#dealTitle > span')
deal_titles = []

for deal_title_elem in deal_title_elems:
    deal_titles.append(deal_title_elem.text)

price_elems = driver.find_elements_by_css_selector('.priceBlock > span')
prices = []

for price_elem in price_elems:
    prices.append(price_elem.text)

titles_with_prices = dict(zip(deal_titles, prices))

print(titles_with_prices)

amazon = am.Amazon()
# amazon.reset_database()

for key, value in titles_with_prices.items():
    amazon.add(key, value)