Exemplo n.º 1
0
 def get_product(self, brand, source_id, pid, url):
     try:
         print ('get_product', int(time.time()))
         driver = None
         driver = of_utils.create_chrome_driver()
         driver.get(url)
         if pid == -1: # entry
             return self.parse_entry(driver)
         else: # product
             return self.parse_product(driver)
     finally:
         driver.quit()
Exemplo n.º 2
0
 def proc(self, brand, source_id, pid, url):
     driver = None
     try:
         driver = of_utils.create_chrome_driver()
         driver.get(url)
         try:
             if pid == -1:  # entry
                 result = self.parse_entry(driver)
             else:  # product
                 result = self.parse_product(driver)
             status = of_config.status_finished
         except Exception as e:
             result = traceback.format_exc()
             status = of_config.status_failed
         self.write_products(brand, url, source_id, pid, status, result)
     except Exception as e:
         self.logger.exception(traceback.format_exc())
     finally:
         if driver:
             driver.quit()
Exemplo n.º 3
0
import sys
import traceback
sys.path.append('.')
import of_utils


def parse_entry(driver):
    elements = of_utils.find_elements_by_css_selector(
        driver, 'div.product > div.inner > figure > a')
    return [element.get_attribute('href').strip() for element in elements]


if __name__ == '__main__':
    driver = None
    try:
        driver = of_utils.create_chrome_driver()
        driver.get('https://www.giuseppezanotti.cn/woman/shoes')
        products = parse_entry(driver)
        print(products)
        print(len(products))
    except Exception as e:
        print(e)
        print(traceback.format_exc())
    finally:
        if driver:
            driver.quit()