python智联招聘爬虫并导入到excel代码实例

yipeiwu_com6年前Python爬虫

这篇文章主要介绍了python智联招聘爬虫并导入到excel代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

写了一个智联招聘的爬虫,只要输入职位关键字,就能快速导出智联招聘上的数据,存在excel表里~

import requests,openpyxl
#建立excel表
joblist=[]
wb=openpyxl.Workbook()
sheet=wb.active
sheet.title='智联招聘数据'
sheet['A1']='职位名称'
sheet['B1']='薪资'
sheet['C1']='工作经验'
#爬虫
keyword=str(input('请输入查找职位的关键字:'))
url='https://fe-api.zhaopin.com/c/i/sou'
headers={
  'Referer': 'https://sou.zhaopin.com/?p=2&jl=653&et=2&kw=%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90&kt=3&sf=0&st=0',
  'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15'
  }
for n in range(5):
  params={
    'start': str(90*n),
    'pageSize': '90',
    'cityId': '653',
    'salary': '0,0',
    'workExperience': '-1',
    'education':'4',
    'companyType': '-1',
    'employmentType': '2',
    'jobWelfareTag': '-1',
    'kw': keyword,
    'kt': '3',
    'at': '9faf2d5cc87b4141a33c493c248ce1eb',
    'rt': 'c678689ef9144475b2030fe55c12fe5c',
    '_v': '0.53075950',
    'userCode': '638259962',
    'x-zp-page-request-id': '9eb3c2c955dd4a8db3c8224a177ebdd5-1567575573029-133510',
    'x-zp-client-id': 'cd7e0b11-a761-4a2f-a8be-2e6a9da3f068'
    }  
  res=requests.get(url,headers=headers,params=params)
  jsonres=res.json()
  positions=jsonres['data']['results']
  for position in positions:
    jobname=position['jobName']
    salary=position['salary']
    workingExp=position['workingExp']['name']
    joblist.append([jobname,salary,workingExp])
#写入excel
for row in joblist:
  sheet.append(row)  
wb.save('智联招聘数据.xlsx')
print('数据爬取成功!')

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python爬虫之BeautifulSoup 使用select方法详解

本文介绍了python爬虫之BeautifulSoup 使用select方法详解 ,分享给大家。具体如下: <html><head><title>...

python爬虫教程之爬取百度贴吧并下载的示例

测试url:http://tieba.baidu.com/p/27141123322?pn=begin  1end   4复制代码 代码如下:import...

Python开发实例分享bt种子爬虫程序和种子解析

看到网上也有开源的代码,这不,我拿来进行了二次重写,呵呵,上代码:  #encoding: utf-8     &n...

Python爬虫工程师面试问题总结

注:答案一般在网上都能够找到。 1.对if __name__ == 'main'的理解陈述 2.python是如何进行内存管理的? 3.请写出一段Python代码实现删除一个lis...

python爬取酷狗音乐排行榜

本文为大家分享了python爬取酷狗音乐排行榜的具体代码,供大家参考,具体内容如下 #coding=utf-8 from pymongo import MongoClient im...