本文整理汇总了Python中scrapy.Field方法的典型用法代码示例。如果您正苦于以下问题:Python scrapy.Field方法的具体用法?Python scrapy.Field怎么用?Python scrapy.Field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy
的用法示例。
在下文中一共展示了scrapy.Field方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_errors_to_item
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def _add_errors_to_item(self, item, errors):
try:
if self.errors_field not in item.__class__.fields:
item.__class__.fields[self.errors_field] = Field()
if self.errors_field not in item._values:
item[self.errors_field] = defaultdict(list)
except AttributeError:
# The item is just a dict object instead of a Scrapy.Item object
if self.errors_field not in item:
item[self.errors_field] = defaultdict(list)
for field_name, messages in errors.items():
item[self.errors_field][field_name] += messages
示例2: custom_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def custom_field():
return scrapy.Field(input_processor=MapCompose(DataUtils.remove_html), output_processor=Join())
示例3: numeric_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def numeric_field():
return scrapy.Field(input_processor=MapCompose(DataUtils.remove_html), output_processor=TakeFirst())
示例4: price_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def price_field():
return scrapy.Field(input_processor=MapCompose(
lambda value: value.replace('$', '') if type(value) == str else value,
DataUtils.remove_html, float),
output_processor=TakeFirst())
示例5: url_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def url_field():
return scrapy.Field(input_processor=MapCompose(DataUtils.remove_html,
lambda value: value \
.replace('//', '/') \
.replace('https:/', 'https://') \
.replace('http:/', 'http://') \
.rstrip('/')),
output_processor=Join())
示例6: category_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def category_field():
return scrapy.Field(output_processor=Join())
示例7: date_field
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def date_field():
def parse_date(value):
date_format = value['date_format']
time_utils = TimeUtils(date_format=date_format)
date_obj = {**create_time_data(), **value}
start_timestamp, end_timestamp = time_utils.get_timestamps(date_obj)
return {
'start_timestamp': start_timestamp,
'end_timestamp': end_timestamp
}
return scrapy.Field(input_processor=MapCompose(DataUtils.remove_html, parse_date), output_processor=TakeFirst())
示例8: help_fields
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def help_fields(self):
for field in self.field_list:
print(field, "= scrapy.Field()")
示例9: help_fields
# 需要导入模块: import scrapy [as 别名]
# 或者: from scrapy import Field [as 别名]
def help_fields(self):
for field in self.fields:
print(field, "= scrapy.Field()")