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

yipeiwu_com4年前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爬虫 基于requests模块的get请求实现详解

需求:爬取搜狗首页的页面数据 import requests # 1.指定url url = 'https://www.sogou.com/' # 2.发起get请求:get方法会返...

python爬虫之遍历单个域名

即使你没听说过“维基百科六度分隔理论”,也很可能听过“凯文 • 贝肯 (Kevin Bacon)的六度分隔值游戏”。在这两个游戏中,目标都是把两 个不相干的主题(在前一种情况...

Python爬虫使用脚本登录Github并查看信息

Python爬虫使用脚本登录Github并查看信息

前言分析目标网站的登录方式 目标地址: https://github.com/login    登录方式做出分析: 第一,用form表单方式提交信息, 第二...

scrapy spider的几种爬取方式实例代码

本节课介绍了scrapy的爬虫框架,重点说了scrapy组件spider。 spider的几种爬取方式: 爬取1页内容 按照给定列表拼出链接爬取多页 找到‘下一页'标签进行...

Python多线程爬虫简单示例

 python是支持多线程的,主要是通过thread和threading这两个模块来实现的。thread模块是比较底层的模块,threading模块是对thread做了一些包装...