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爬虫实现使用beautifulSoup4爬取名言网功能案例

本文实例讲述了Python爬虫实现使用beautifulSoup4爬取名言网功能。分享给大家供大家参考,具体如下: 爬取名言网top10标签对应的名言,并存储到mysql中,字段(名言,...

python中数据爬虫requests库使用方法详解

python中数据爬虫requests库使用方法详解

一、什么是Requests Requests 是Python语编写,基于urllib,采Apache2 Licensed开源协议的 HTTP 库。它urllib 更加方便,可以节约我们大...

Python爬取国外天气预报网站的方法

本文实例讲述了Python爬取国外天气预报网站的方法。分享给大家供大家参考。具体如下: crawl_weather.py如下: #encoding=utf-8 import http...

Python 爬虫图片简单实现

Python 爬虫图片简单实现 经常在逛知乎,有时候希望把一些问题的图片集中保存起来。于是就有了这个程序。这是一个非常简单的图片爬虫程序,只能爬取已经刷出来的部分的图片。由于对这一部分内...

使用python爬取B站千万级数据

使用python爬取B站千万级数据

Python(发音:英[?pa?θ?n],美[?pa?θɑ:n]),是一种面向对象、直译式电脑编程语言,也是一种功能强大的通用型语言,已经具有近二...