def write_excel(lists, filename): wb = Workbook() ws = wb.active ws.title = "职位信息" ws.cell(row=1, column=1).value = '发布时间' ws.cell(row=1, column=2).value = '工作时间' ws.cell(row=1, column=3).value = '职位名称' ws.cell(row=1, column=4).value = '职位ID' ws.cell(row=1, column=5).value = '公司ID' ws.cell(row=1, column=6).value = '职位类型' ws.cell(row=1, column=7).value = '公司名称' ws.cell(row=1, column=8).value = '所在城市' ws.cell(row=1, column=9).value = '文化程度' ws.cell(row=1, column=10).value = '所属行业' ws.cell(row=1, column=11).value = '融资阶段' ws.cell(row=1, column=12).value = '职位薪酬' ws.cell(row=1, column=13).value = '公司规模' ws.cell(row=1, column=14).value = '平均薪资' rownum = 2 for each_item in lists: info_list = each_item.get('joblist') for each_job_info_obj in info_list: ws.cell(row=rownum, column=1).value = each_job_info_obj['formatCreateTime'] ws.cell(row=rownum, column=2).value = each_job_info_obj['workYear'] ws.cell(row=rownum, column=3).value = each_job_info_obj['positionName'] ws.cell(row=rownum, column=4).value = each_job_info_obj['positionId'] ws.cell(row=rownum, column=5).value = each_job_info_obj['companyId'] ws.cell(row=rownum, column=6).value = each_job_info_obj['positionType'] ws.cell(row=rownum, column=7).value = each_job_info_obj['companyName'] ws.cell(row=rownum, column=8).value = each_job_info_obj['city'] ws.cell(row=rownum, column=9).value = each_job_info_obj['education'] ws.cell(row=rownum, column=10).value = each_job_info_obj['industryField'] ws.cell(row=rownum, column=11).value = each_job_info_obj['financeStage'] ws.cell(row=rownum, column=12).value = each_job_info_obj['salary'] ws.cell(row=rownum, column=13).value = each_job_info_obj['companySize'] ws.cell(row=rownum, column=14).value = toolkit.normalize( each_job_info_obj['salary']) rownum += 1 wb.save('d:/' + filename + '.xlsx') logging.info('Excel生成成功!')
def write_excel(lists, filename): wb = Workbook() ws = wb.active ws.title = "职位信息" ws.cell(row=1, column=1).value = '发布时间' ws.cell(row=1, column=2).value = '工作时间' ws.cell(row=1, column=3).value = '职位名称' ws.cell(row=1, column=4).value = '职位ID' ws.cell(row=1, column=5).value = '公司ID' ws.cell(row=1, column=6).value = '职位类型' ws.cell(row=1, column=7).value = '公司名称' ws.cell(row=1, column=8).value = '所在城市' ws.cell(row=1, column=9).value = '文化程度' ws.cell(row=1, column=10).value = '所属行业' ws.cell(row=1, column=11).value = '融资阶段' ws.cell(row=1, column=12).value = '职位薪酬' ws.cell(row=1, column=13).value = '公司规模' ws.cell(row=1, column=14).value = '平均薪资' rownum = 2 for each_item in lists: info_list = each_item.get('joblist') for each_job_info_obj in info_list: ws.cell(row=rownum, column=1).value = each_job_info_obj['formatCreateTime'] ws.cell(row=rownum, column=2).value = each_job_info_obj['workYear'] ws.cell(row=rownum, column=3).value = each_job_info_obj['positionName'] ws.cell(row=rownum, column=4).value = each_job_info_obj['positionId'] ws.cell(row=rownum, column=5).value = each_job_info_obj['companyId'] ws.cell(row=rownum, column=6).value = each_job_info_obj['positionType'] ws.cell(row=rownum, column=7).value = each_job_info_obj['companyName'] ws.cell(row=rownum, column=8).value = each_job_info_obj['city'] ws.cell(row=rownum, column=9).value = each_job_info_obj['education'] ws.cell(row=rownum, column=10).value = each_job_info_obj['industryField'] ws.cell(row=rownum, column=11).value = each_job_info_obj['financeStage'] ws.cell(row=rownum, column=12).value = each_job_info_obj['salary'] ws.cell(row=rownum, column=13).value = each_job_info_obj['companySize'] ws.cell(row=rownum, column=14).value = toolkit.normalize(each_job_info_obj['salary']) rownum += 1 wb.save('d:/' + filename + '.xlsx') print('Excel生成成功!')
def write_excel(output_path, lists, filename): wb = Workbook() ws = wb.active ws.title = "职位信息" ws.cell(row=1, column=1).value = '发布时间' ws.cell(row=1, column=2).value = '工作时间' ws.cell(row=1, column=3).value = '职位名称' ws.cell(row=1, column=4).value = '公司名称' ws.cell(row=1, column=5).value = '公司规模' ws.cell(row=1, column=6).value = '所在城市' ws.cell(row=1, column=7).value = '学历要求' ws.cell(row=1, column=8).value = '工作经验' ws.cell(row=1, column=9).value = '职位薪酬' ws.cell(row=1, column=10).value = '平均薪资' rownum = 2 for each_item in lists: info_list = each_item.get('joblist') for each_job_info_obj in info_list: ws.cell(row=rownum, column=1).value = each_job_info_obj['formatCreateTime'] ws.cell(row=rownum, column=2).value = each_job_info_obj['workYear'] ws.cell(row=rownum, column=3).value = each_job_info_obj['positionName'] ws.cell(row=rownum, column=4).value = each_job_info_obj['companyFullName'] ws.cell(row=rownum, column=5).value = each_job_info_obj['companySize'] ws.cell(row=rownum, column=6).value = each_job_info_obj['city'] ws.cell(row=rownum, column=7).value = each_job_info_obj['education'] ws.cell(row=rownum, column=8).value = each_job_info_obj['workYear'] ws.cell(row=rownum, column=9).value = each_job_info_obj['salary'] ws.cell(row=rownum, column=10).value = toolkit.normalize( each_job_info_obj['salary']) rownum += 1 wb.save(output_path + filename + '.xlsx') print('Excel生成成功!')
def write_csv(output_path, lists, filename): f = open(output_path + filename + '.csv', 'wt', encoding='utf-8') f.write('发布时间,工作时间,职位名称,公司名称,公司规模,所在城市,学历要求,工作经验,单位薪酬,平均薪资') f.write('\n') for each_item in lists: info_list = each_item.get('joblist') for each_job_info_obj in info_list: f.write(each_job_info_obj['formatCreateTime'] + ',' + each_job_info_obj['workYear'] + ',' + each_job_info_obj['positionName'] + ',' + str(each_job_info_obj['positionId']) + ',' + str(each_job_info_obj['companyId']) + ',' + each_job_info_obj['positionAdvantage'] + ',' + each_job_info_obj['companyFullName'] + ',' + each_job_info_obj['city'] + ',' + each_job_info_obj['education'] + ',' + each_job_info_obj['industryField'] + ',' + each_job_info_obj['financeStage'] + ',' + each_job_info_obj['salary'] + ',' + str(each_job_info_obj['companySize']) + ',' + str(toolkit.normalize(each_job_info_obj['salary']))) f.write('\n') f.flush() f.close()