本文整理汇总了Python中scrapy.http.request.Request.meta['cate']方法的典型用法代码示例。如果您正苦于以下问题:Python Request.meta['cate']方法的具体用法?Python Request.meta['cate']怎么用?Python Request.meta['cate']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.http.request.Request
的用法示例。
在下文中一共展示了Request.meta['cate']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_requests
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta['cate'] [as 别名]
def start_requests(self):
for cate in cate_array :
item_list_interface_url = u'http://api.youzibuy.com/brand_area_catalog/item_list?v=1.2.2&size=0&catalog_id=%s&group_id=%s'%(cate['catalog_id'],cate['group_id'])
for i in xrange(1,load_page_count_per_api+1):
request = Request('%s&page=%d'%(item_list_interface_url,i))
request.meta['cate'] = cate
# print '----------------------'+request.url
yield request
示例2: parse
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta['cate'] [as 别名]
def parse(self, response):
try:
cate = response.request.meta['cate']
jsonObj = json.loads(response.body)
if 'group_id' in cate:
u'''
{
status: true,
code: 200,
msg: "",
data: {
list_style: 1,
item_list: [
{
brand_area_id: 51526,
name: "解决干枯毛躁静电香水护发精油80ml ",
id: 212171,
brand_id: 0,
item_id: "AAHW6jHtAB3qoKkvnrPIrSyx",
picture: "http://sc.seeyouyima.com/taobao/web_shopGuide5757f932125e1.png?imageView2/1/h/300/w/300/",
start_at: "0000-00-00 00:00:00",
end_at: "0000-00-00 00:00:00",
redirect_type: "1",
tag_icon: "0",
promotion_ids: "5",
coin_amount: 0,
purchase_price: 0,
is_active: "1",
order_count: 2008,
promotion_custom: "",
shop_type: "1",
redirect_brand_area_id: 51526,
is_redirect_detail: "0",
status: "0",
tb_price: 8.8,
vip_price: "8.8",
original_price: 19.8,
stock: -1,
tb_stock: 1397177,
open_id: "530844199508",
specs: "",
promotion_type: "0",
jingqi_item_id: "AAHW6jHtAB3qoKkvnrPIrSyx",
item_type: "2",
tb_order_count: 1613,
weekly_click_count: 3213,
brand_area_is_active: "1",
brand_area_start_at: "2016-06-23 09:50:00",
brand_area_end_at: "2016-06-27 10:00:00",
brand_area_name: "6.23个护美加分超级爆款精油",
activity_id: 1,
is_new: 0,
sttag_text: "",
sttag_type: 0,
promotion_text_arr: [
"包邮"
],
is_liked: 0,
link_value: "AAHW6jHtAB3qoKkvnrPIrSyx",
item_count_msg: "共5款",
redirect_url: "",
item_shop_type: "1",
purchase_btn: "1613人已购"
},
],
has_more: 0,
page: 4
}
}
'''
if jsonObj['code'] == 200:
itemList = jsonObj['data']['item_list']
for item in itemList:
yzjItem = YouzijieItem()
# open_id = scrapy.Field() #item_id
# name = scrapy.Field() #名称
# picture = scrapy.Field() #图片地址
# vip_price = scrapy.Field() #柚子街价格
# original_price = scrapy.Field() #原价
# brand_area_start_at = scrapy.Field() #开始时间
# brand_area_end_at = scrapy.Field() #结束时间
# promotion_text_arr = scrapy.Field() #包邮
# redirect_brand_area_id = scrapy.Field() #专题id,0:不是专题,1:专题id
if item['redirect_brand_area_id'] != 0:
request = Request('http://api.youzibuy.com/tae_item_list?v=1.2.2&brand_area_id=%d&page=1'%(item['redirect_brand_area_id']))
request.meta['cate'] = {'cate_title':response.request.meta['cate']['cate_title'],'zhuanchang_title':item['brand_area_name']}
print '---------redirect_brand_area_id-------------'+request.url
yield request
yzjItem['open_id'] = item['open_id']
yzjItem['name'] = item['name']
#.........这里部分代码省略.........