您的位置:首页 > 其它

scrapy框架学习-爬取腾讯社招信息-item字段和管道文件

2017-12-24 15:50 330 查看
item

# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html 
import scrapy

class TenxunItem(scrapy.Item):
# define the fields for your item here like:
job_name = scrapy.Field()

job_link = scrapy.Field()

job_type = scrapy.Field()

job_people_num = scrapy.Field()

job_site = scrapy.Field()

publish_time = scrapy.Field()


pipelines

# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html 
import json

class TenxunPipeline(object):
def __init__(self):
self.f = open("tencent.json", "w")

def process_item(self, item, spider):
content = json.dumps(dict(item),
ensure_ascii=False) + ",\n"                                                             "\n"
self.f.write(content)
return item

def close_spider(self, spider):
self.f.close()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐