def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector(driver, '.product_header_name>h3') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/ element = of_utils.find_element_by_css_selector(driver,'.product__product-details-shade-name') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector(driver, '.product__price>span') if element: product['price_cny'] = of_utils.convert_price( element.text.strip()) # images images = [] element = of_utils.find_element_by_css_selector(driver, "meta[property='og:image']") if element: images.append(element.get_attribute('content')) product['images'] = ';'.join(images) # detail N/A return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.pdp-title-product>div>h1') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector(driver, '#product-id') if element: product['code'] = element.get_attribute('value') # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-add-to-cart .product-price>span') if element: product['price_cny'] = of_utils.convert_price( element.text.strip().replace('CNY', '')) # images elements = of_utils.find_elements_by_css_selector( driver, '.simple-slide-wrapper > div > a') images = [ element.get_attribute('href').strip() for element in elements ] product['images'] = ';'.join(images) # detail N/A return product
def parse_product(self, driver): product = of_spider.empty_product.copy() #title element = of_utils.find_element_by_css_selector( driver, '#product-content .product-name') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A element = of_utils.find_element_by_css_selector( driver, '#product-content .product-number span') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '#product-content .product-price .price-sales') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '#pdpMain .primary-image') images = [element.get_attribute('src') for element in elements] images = {}.fromkeys(images).keys() product['images'] = ';'.join(images) # detail N/A return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.details_info_title>h1') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, '.details_info_code') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.details_price_new>span') if element: product['price_cny'] = of_utils.convert_price( element.text.strip().replace(',00', '').replace('.', '')) # images elements = of_utils.find_elements_by_css_selector( driver, '.MagicZoom > figure > img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_css_selector( driver, '.details_info_descr') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): of_utils.sleep(2) product = of_spider.empty_product.copy() ele = of_utils.find_element_by_css_selector(driver, 'div.product-name>h1') product['title'] = ele.text.strip() if ele else '' ele = of_utils.find_element_by_css_selector(driver, 'div[itemprop=sku]') product['code'] = ele.text.strip() if ele else '' ele = of_utils.find_element_by_css_selector(driver, 'meta[itemprop=price]') product['price_cny'] = of_utils.convert_price(ele.get_attribute('content').strip()) if ele else 0 # images imgs=[] eles = of_utils.find_elements_by_css_selector(driver, '.fotorama__thumb>img') if not eles: eles = of_utils.find_elements_by_css_selector(driver, '.fotorama__stage__frame>img') for ele in eles: img = ele.get_attribute('src').strip().replace('cache', '') for a in img.split('/'): if len(a) == 32: img = img.replace(a,'') imgs.append(img) product['images'] = ';'.join(imgs) return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.product-info .info') if element: product['title'] = element.text.strip().replace('"', '') else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, '.product-info .sku') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-info .price') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.ql-product-image img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail N/A return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '#product-name') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector(driver, '#skuCode') if element: product['code'] = element.get_attribute('value') # price_cny element = of_utils.find_element_by_css_selector(driver, '#retailPrice') if element: product['price_cny'] = of_utils.convert_price( element.get_attribute('value')) # images elements = of_utils.find_elements_by_css_selector( driver, '.product-thumb-list>a>img') images = [ element.get_attribute('src').strip().replace('S_NEW', 'H_NEW') for element in elements ] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_css_selector( driver, '.product-description') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, 'div.media__body>h1') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, '.product-page-ref') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-page-price span[itemprop=price]') if element: price_text = element.text.strip() # 去掉开头的¥ product['price_cny'] = of_utils.convert_price(price_text) # images elements = of_utils.find_elements_by_css_selector( driver, '#product-slider .slider__body .slider__item img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_css_selector(driver, '.pdgt-') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//div[@class="product-title "]/h2[@class="product-name"][1]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="price-row"]//h2[@class="price-sales"][1]') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//li[contains(@class,"productthumbnail")]/img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A element = of_utils.find_element_by_xpath( driver, '//div[@class="pdp-tab-content"]/p') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//h1[@class="pDetails__title"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath( driver, '//div[@id="mainPdpContent"]') if element: product['code'] = element.get_attribute('data-partnumber') # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class=" pDetails__priceItem"]//span[@class="price__value"]' ) if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//div[@class="pDetails__slide js-imgProduct slick-slide"]//img') images = [element.get_attribute('src') for element in elements] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail element = of_utils.find_element_by_xpath( driver, '//p[@class="pDetails__desc"]') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.pdp-details-desktop>h1') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, '.code-value-pdp') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.pdp-details-desktop .pdp-list-price') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.pdp-thumbnails .thumbnails .wrapper a') images = [ element.get_attribute('href').strip() for element in elements ] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_css_selector( driver, '.pdp_longdescription') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//h3[@class="component-products-head-line__title font-bemboStd"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath( driver, '//p[@class="page-products-id__code"]') if element: product['code'] = element.text.strip().replace('商品代码:', '') # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="component-products-head-line__price"]') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//li[@class="component-products-pictures__item"]/img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_xpath( driver, '//p[@class="page-products-id__describe"]') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(10) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector(driver, '.iwc-buying-options-title') if element: product['title'] = element.text.strip().replace('\n添加至我的愿望清单','') else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector(driver, '.iwc-buying-options-reference') if element: product['code'] = element.text.strip() product['title'] = product['title'] + ' ' + element.text.strip() # price_cny element = of_utils.find_element_by_css_selector(driver, '.iwc-buying-options-price') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector(driver, '.iwc-buying-option-thumbnails .iwc-watch-thumbnail-container:not(.slick-cloned) .iwc-watch-thumbnail') images = ['https://www.iwc.cn'+ element.get_attribute('data-srcset').strip() for element in elements] product['images'] = ';'.join(images) # detail elements = of_utils.find_elements_by_css_selector(driver, 'ul.detailList > li') texts = [element.text.strip() for element in elements] product['detail'] = '\n'.join(texts).strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//div[@class="prod_detzone_info"]/h3') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath( driver, '//div[@class="prod_detzone_info"]/div[@class="dec"]') if element: product['code'] = element.text.strip().replace('款号:', '') # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="prod_detzone_info"]/h4') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//div[@class="pic_all texiao"]/div') images = [ element.get_attribute('data-bigimg').strip() for element in elements ] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A element = of_utils.find_element_by_xpath( driver, '//div[@class="note"]/small[1]') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//h1[@class="product-detail_name"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath( driver, '//p[contains(@class,"itemNum")]') if element: product['code'] = element.text.strip().replace('ITEM: ', '') # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="product-detail_price"]') if element: product['price_cny'] = of_utils.convert_price( element.text.strip().replace('CN¥', '')) # images elements = of_utils.find_elements_by_xpath( driver, '//img[@class="product-imagery_picture-image"]') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A element = of_utils.find_element_by_xpath( driver, '//div[contains(@class,"description")]/p') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//div[@class="product-name alternate"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_xpath( driver, '//span[@class="price-sales"]') if element: product['price_usd'] = of_utils.convert_price( element.text.strip().replace('$', '')) # images elements = of_utils.find_elements_by_xpath( driver, '//a[@class="product-image main-image"]/picture/img') images = [ element.get_attribute('srcset').strip() for element in elements ] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, ".container h1") if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code # price_cny element = of_utils.find_element_by_css_selector( driver, '.container .col2 .price .formatted_price') if element: arr = re.findall(r"¥(.*)", element.text.strip()) if arr: product['price_cny'] = of_utils.convert_price(arr[0]) # images elements = of_utils.find_elements_by_css_selector( driver, '.product-img') if elements: images = [ element.get_attribute('src').strip() for element in elements ] product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector(driver, ".abstract") if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//h1[@class="product-name-title"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath(driver, '//li[@class="product-id"]') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="primary-category-and-price"]//span[@class="sales "]' ) if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//div[@class="primary-images"]//div[@class="swiper-wrapper"]//img' ) images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A element = of_utils.find_element_by_xpath( driver, '//div[@class="info-and-care product-attributes"]/ul') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, 'h1.product-info-h1') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-info .price') if element: product['price_cny'] = of_utils.convert_price( element.text.strip().replace('ml', '')) # images elements = of_utils.find_elements_by_css_selector( driver, '.product-pic .item img') if not elements: elements = of_utils.find_elements_by_css_selector( driver, '.productpage-images .productpage-image img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_css_selector( driver, '.tab-product-info') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector(driver, '.page-title') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A element = of_utils.find_element_by_css_selector(driver, '.product-sku') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, "meta[itemprop='price") if element: product['price_cny'] = of_utils.convert_price( element.get_attribute('content')) # images elements = of_utils.find_elements_by_css_selector( driver, '.product.media .swiper-slide img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector( driver, '.watch-info-item>p') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): of_utils.sleep(4) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.product-information .product-name') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-information .product-price .p-price') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.product-information .product-details-image-gallery img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector( driver, '.product-information .product-short-description') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//h1[@class="product-name"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A element = of_utils.find_element_by_xpath(driver, '//span[@itemprop="price"]') if element: product['price_cny'] = of_utils.convert_price( element.get_attribute('content')) # images elements = of_utils.find_elements_by_xpath( driver, '//meta[@property="og:image"]') images = [ element.get_attribute('content').strip() for element in elements ] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail element = of_utils.find_element_by_xpath( driver, '//p[@id="collapseDescription"]') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): of_utils.sleep(5) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath( driver, '//i[@class="iconfont icon-ICON_share"]/..') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath(driver, '//div[@class="code"]') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_xpath( driver, '//div[@class="product-price"]/i') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath( driver, '//ul[@class="small-img-list"]/li/img') images = [ element.get_attribute('data-src').strip().split('?x-oss-process') [0] for element in elements ] product['images'] = ';'.join({}.fromkeys(images).keys()) # detail N/A element = of_utils.find_element_by_xpath( driver, '//div[@class="desc"]//div[@class="content"]') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, ".productName .modelName") if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, ".skuContainer .value") if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.itemPrice .value') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.alternativeImages img') if elements: images = [ element.get_attribute('src').strip() for element in elements ] product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector( driver, ".editorialdescription>.value") if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): driver.implicitly_wait(15) product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_xpath(driver, '//div[@class="product-info-section"]//h1[@class="product-name"]') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_xpath(driver, '//span[@class="product-sku"]') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_xpath(driver, '//div[@class="product-info-section"]//span[@class="price bold-family"]') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_xpath(driver, '//div[contains(@class,"swiper-item cursor-zoom swiper-slide")]/img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail element = of_utils.find_element_by_xpath(driver, '//div[@class="item-description"]/div') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.page-header .title-cap') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_css_selector( driver, '.primary-details .price-box .price') if element: product['price_usd'] = of_utils.convert_price( element.text.replace('C', '').replace('$', '').strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.product-main>.swiper-container>.swiper-wrapper>img') images = [element.get_attribute('src').strip() for element in elements] images = {}.fromkeys(images).keys() product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector(driver, '.description') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.page-title>span') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-info-price .price') if element: product['price_cny'] = of_utils.convert_price( element.text.replace('¥', '').strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.fotorama__stage__shaft>div>img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail N/A element = of_utils.find_element_by_css_selector( driver, "meta[property='og:description']") if element: product['detail'] = element.get_attribute('content').strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.product-full__subline') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code N/A # price_cny element = of_utils.find_element_by_css_selector( driver, '.product-full__content .product-sku-price__value') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # # images elements = of_utils.find_elements_by_css_selector( driver, '.product-full__image-carousel .product-full__carousel__slides .product-full__carousel__slide img' ) images = [ 'https://www.lamer.com.cn' + element.get_attribute('data-src').strip() for element in elements ] product['images'] = ';'.join(images) # # detail element = of_utils.find_element_by_css_selector( driver, '.product-full__description .product-full__accordion__panel') if element: product['detail'] = element.text.strip() return product
def parse_product(self, driver): product = of_spider.empty_product.copy() # title element = of_utils.find_element_by_css_selector( driver, '.mb-pdp-heading') if element: product['title'] = element.text.strip() else: raise Exception('Title not found') # code element = of_utils.find_element_by_css_selector( driver, '.mb-pdp-prod-ident') if element: product['code'] = element.text.strip() # price_cny element = of_utils.find_element_by_css_selector( driver, '.mb-pdp-price') if element: product['price_cny'] = of_utils.convert_price(element.text.strip()) # images elements = of_utils.find_elements_by_css_selector( driver, '.slick-slide:not(.slick-cloned) img') images = [element.get_attribute('src').strip() for element in elements] product['images'] = ';'.join(images) # detail N/A return product
def getDetailCn(url): product = of_spider.empty_product.copy() options = webdriver.ChromeOptions() options.add_argument('--ignore-certificate-errors') driver = webdriver.Chrome(chrome_options=options) driver.maximize_window() driver.get(url) driver.implicitly_wait(15) try: product['url'] = url product['title'] = of_utils.find_element_by_css_selector( driver, '.spice-product-name').text.strip() product['code'] = of_utils.find_element_by_css_selector( driver, '.spice-style-number-title > span').text.strip() product['price_cny'] = of_utils.convert_price( of_utils.find_element_by_css_selector(driver, '.goods-price').text.strip()) product['images'] = of_utils.find_element_by_css_selector( driver, '#product_main_image_0 img').get_attribute('srcset') return product except Exception as e: print(e) print(traceback.format_exc()) finally: driver.quit()