1. 文章中会调用百度翻译api 接口 so 先申请下 百度翻译api
下载下demo 测试一下
获取 图骗
item['img'] = zong.xpath('div[@id="detail"]/div[@class="tb-detail-bd tb-clear"]/div[@class="tb-summary tb-clear"]/div[@class="tb-item-info tb-clear"]/div[@class="tb-item-info-l"]/div[@class="tb-gallery"]/div[@class="tb-booth tb-pic tb-main-pic"]/a/img/@src').extract()
获取名称
name=zong.xpath('div[@id="detail"]/div[@class="tb-detail-bd tb-clear"]/div[@class="tb-summary tb-clear"]/div[@class="tb-item-info tb-clear"]/div[@class="tb-item-info-r"]/div[@class="tb-property tb-property-x"]/div[@class="tb-wrap tb-wrap-newshop"]/div[@class="tb-title"]/h3[@class="tb-main-title"]/text()').extract()
获取价格
item['price'] =zong.xpath('div[@id="detail"]/div[@class="tb-detail-bd tb-clear"]/div[@class="tb-summary tb-clear"]/div[@class="tb-item-info tb-clear"]/div[@class="tb-item-info-r"]/div[@class="tb-property tb-property-x"]/div[@class="tb-wrap tb-wrap-newshop"]/ul[@class="tb-meta tb-promo-meta"]/li[@class="tb-detail-price tb-promo-price tb-clear"]/div[@class="tb-property-cont"]/div[@class="tb-promo-mod"]/div[@class="tb-promo-hd tb-promo-item"]/div[@class="tb-promo-item-bd"]/strong[@class="tb-promo-price"]/em[@class="tb-rmb-num"]/text()').extract()
获取 尺码
item['chima'] =zong.xpath('div[@id="detail"]/div[@class="tb-detail-bd tb-clear"]/div[@class="tb-summary tb-clear"]/div[@class="tb-item-info tb-clear"]/div[@class="tb-item-info-r"]/div[@class="tb-property tb-property-x"]/div[@class="tb-wrap tb-wrap-newshop"]/div[@class="tb-key tb-key-sku"]/div[@class="tb-skin"]/dl[@class="J_Prop J_TMySizeProp tb-prop tb-clear J_Prop_measurement "]/dd/ul[@class="J_TSaleProp tb-clearfix"]/li/a/span/text()').extract()
获取颜色
item['yanse']=zong.xpath('div[@id="detail"]/div[@class="tb-detail-bd tb-clear"]/div[@class="tb-summary tb-clear"]/div[@class="tb-item-info tb-clear"]/div[@class="tb-item-info-r"]/div[@class="tb-property tb-property-x"]/div[@class="tb-wrap tb-wrap-newshop"]/div[@class="tb-key tb-key-sku"]/div[@class="tb-skin"]/dl[@class="J_Prop tb-prop tb-clear J_Prop_Color "]/dd/ul[@class="J_TSaleProp tb-img tb-clearfix"]/li/a/span/text()').extract()
获取规则
item['guize'] =zong.xpath('div[@class="layout grid-s5m0 tb-main-layout"]/div[@class="col-main clearfix"]/div[@class="main-wrap J_TRegion"]/div[@class="sub-wrap"]/div[@class="attributes"]/ul[@class="attributes-list"]/li/text()').extract()
获取详情页
item['xiangqingye']= zong.xpath('div[@class="layout grid-s5m0 tb-main-layout"]/div[@class="col-main clearfix"]/div[@class="main-wrap J_TRegion"]/div[@class="sub-wrap"]/div[@class="J_DetailSection tshop-psm ke-post"]/div[@class="content"]/p/img/@src').extract()