职位爬虫

import requests
from lxml import etree cookie = {
'Cookie':'user_trace_token=20181015184304-692c4bf4-4e71-4cfd-8906-6219253e0ae8; _ga=GA1.2.1135099826.1539600208; LGUID=20181015184305-18c8e815-d067-11e8-bc15-5254005c3644; index_location_city=%E5%85%A8%E5%9B%BD; _gid=GA1.2.73712408.1539738633; sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221667fc4129f205-01a02c2a87905b-51422e1f-2073600-1667fc412a0a16%22%2C%22%24device_id%22%3A%221667fc4129f205-01a02c2a87905b-51422e1f-2073600-1667fc412a0a16%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; JSESSIONID=ABAAABAAADEAAFI1F6DEB9C84C5A5AADBE0CCBE43481EB7; _gat=1; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1539600208,1539738633,1539769054; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1539769054; LGSID=20181017173710-3879f572-d1f0-11e8-bb7a-525400f775ce; PRE_UTM=; PRE_HOST=; PRE_SITE=; PRE_LAND=https%3A%2F%2Fwww.lagou.com%2Fjobs%2Flist_%25E8%25BF%2590%25E7%25BB%25B4%25E5%25B7%25A5%25E7%25A8%258B%25E5%25B8%2588%3Fcity%3D%25E4%25B8%258A%25E6%25B5%25B7%26cl%3Dfalse%26fromSearch%3Dtrue%26labelWords%3D%26suginput%3D; LGRID=20181017173710-3879f6d3-d1f0-11e8-bb7a-525400f775ce; SEARCH_ID=47902a4acdc34c47977e8eeb46c523f2'
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36',
'Accept':'application/json, text/javascript, */*; q=0.01',
'Host':'www.lagou.com',
'Origin':'https://www.lagou.com',
'Referer':'https://www.lagou.com/jobs/list_%E8%BF%90%E7%BB%B4%E5%B7%A5%E7%A8%8B%E5%B8%88?city=%E4%B8%8A%E6%B5%B7&cl=false&fromSearch=true&labelWords=&suginput=',
}
data = {
'first': False,
'pn': 1,
'kd': '运维工程师',
}
def get_job(data):
# url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E6%B7%B1%E5%9C%B3&needAddtionalResult=false&isSchoolJob=0'
url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E4%B8%8A%E6%B5%B7&needAddtionalResult=false'
page = requests.post(url=url, cookies=cookie, headers=headers, data=data)
page.encoding = 'utf-8'
result = page.json()
jobs = result['content']['positionResult']['result']
for job in jobs:
companyShortName = job['companyShortName']
positionId = job['positionId'] # 主页ID
companyFullName = job['companyFullName'] # 公司全名
companyLabelList = job['companyLabelList'] # 福利待遇
companySize = job['companySize'] # 公司规模
industryField = job['industryField']
createTime = job['createTime'] # 发布时间
district = job['district'] # 地区
education = job['education'] # 学历要求
financeStage = job['financeStage'] # 上市否
firstType = job['firstType'] # 类型
secondType = job['secondType'] # 类型
formatCreateTime = job['formatCreateTime']
publisherId = job['publisherId'] # 发布人ID
salary = job['salary'] # 薪资
workYear = job['workYear'] # 工作年限
positionName = job['positionName'] #
jobNature = job['jobNature'] # 全职
positionAdvantage = job['positionAdvantage'] # 工作福利
positionLables = job['positionLables'] # 工种
detail_url = 'https://www.lagou.com/jobs/{}.html'.format(positionId)
response = requests.get(url=detail_url, headers=headers, cookies=cookie)
response.encoding = 'utf-8'
tree = etree.HTML(response.text)
desc = tree.xpath('//*[@id="job_detail"]/dd[2]/div/p/text()') print(companyFullName)
print('%s 拉勾网链接:-> %s' % (companyShortName, detail_url)) print('职位:%s' % positionName)
print('职位类型:%s' % firstType)
print('薪资待遇:%s' % salary)
print('职位诱惑:%s' % positionAdvantage)
print('地区:%s' % district)
print('类型:%s' % jobNature)
print('工作经验:%s' % workYear)
print('学历要求:%s' % education)
print('发布时间:%s' % createTime)
x = ''
for label in positionLables:
x += label + ','
print('技能标签:%s' % x)
print('公司类型:%s' % industryField)
for des in desc:
print(des)
def url(data):
for x in range(1,50):
data['pn'] = x
get_job(data) if __name__ == '__main__':
url(data)

python 爬虫系列03--职位爬虫的更多相关文章

  1. 【网络爬虫入门03】爬虫解析利器beautifulSoup模块的基本应用

    [网络爬虫入门03]爬虫解析利器beautifulSoup模块的基本应用   1.引言 网络爬虫最终的目的就是过滤选取网络信息,因此最重要的就是解析器了,其性能的优劣直接决定这网络爬虫的速度和效率.B ...

  2. java爬虫系列第一讲-爬虫入门

    1. 概述 java爬虫系列包含哪些内容? java爬虫框架webmgic入门 使用webmgic爬取 http://ady01.com 中的电影资源(动作电影列表页.电影下载地址等信息) 使用web ...

  3. python爬虫系列之初识爬虫

    前言 我们这里主要是利用requests模块和bs4模块进行简单的爬虫的讲解,让大家可以对爬虫有了初步的认识,我们通过爬几个简单网站,让大家循序渐进的掌握爬虫的基础知识,做网络爬虫还是需要基本的前端的 ...

  4. python 爬虫系列07-天气爬虫

    看天气 import requests from bs4 import BeautifulSoup ALL_DATA = [] def parse_page(url): headers = { 'Us ...

  5. Python3爬虫系列:理论+实验+爬取妹子图实战

    Github: https://github.com/wangy8961/python3-concurrency-pics-02 ,欢迎star 爬虫系列: (1) 理论 Python3爬虫系列01 ...

  6. 爬虫系列(三) urllib的基本使用

    一.urllib 简介 urllib 是 Python3 中自带的 HTTP 请求库,无需复杂的安装过程即可正常使用,十分适合爬虫入门 urllib 中包含四个模块,分别是 request:请求处理模 ...

  7. 爬虫系列(九) xpath的基本使用

    一.xpath 简介 究竟什么是 xpath 呢?简单来说,xpath 就是一种在 XML 文档中查找信息的语言 而 XML 文档就是由一系列节点构成的树,例如,下面是一份简单的 XML 文档: &l ...

  8. 爬虫系列(五) re的基本使用

    1.简介 究竟什么是正则表达式 (Regular Expression) 呢?可以用下面的一句话简单概括: 正则表达式是一组特殊的 字符序列,由一些事先定义好的字符以及这些字符的组合形成,常常用于 匹 ...

  9. 爬虫系列(七) requests的基本使用

    一.requests 简介 requests 是一个功能强大.简单易用的 HTTP 请求库,可以使用 pip install requests 命令进行安装 下面我们将会介绍 requests 中常用 ...

随机推荐

  1. Java Random、ThreadLocalRandom、UUID类中的方法应用(随机数)

    1.Random:产生一个伪随机数(通过相同的种子,产生的随机数是相同的): Random r=new Random(); System.out.println(r.nextBoolean()); S ...

  2. 解决Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of the configured nodes are available

    Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of ...

  3. C#中Winform程序中如何实现多维表头【不通过第三方报表程序】

    问题:C#中Winform程序中如何实现多维表头. 在网上搜了很多方法,大多数方法对于我这种新手,看的都不是很懂.最后在新浪博客看到了一篇比较易懂的文章:[DataGridView二维表头与合并单元格 ...

  4. Echarts+WPF

    C# using System; using System.Collections.Generic; using System.IO; using System.Linq; using System. ...

  5. 基于CentOS6定制自己的ISO安装光盘

    警告:转载请注明出处 https://www.cnblogs.com/BoyTNT/p/9322927.html  1.目标 >> 基于CentOS-6.10-x86_64-minimal ...

  6. Topshelf + Quartz2.5 创建基于windows服务

    1.创建一个定时调度Quartz类 using Quartz; using Quartz.Impl; using System; using System.Collections.Generic; u ...

  7. 大数据技术之_11_HBase学习_01_HBase 简介+HBase 安装+HBase Shell 操作+HBase 数据结构+HBase 原理

    第1章 HBase 简介1.1 什么是 HBase1.2 HBase 特点1.3 HBase 架构1.3 HBase 中的角色1.3.1 HMaster1.3.2 RegionServer1.3.3 ...

  8. IO模型《二》阻塞IO

    阻塞IO(blocking IO) 在linux中,默认情况下所有的socket都是blocking,一个典型的读操作流程大概是这样: 当用户进程调用了recvfrom这个系统调用,kernel就开始 ...

  9. spring boot日志及Log4j日志配置

    1.默认实现的日志配置 Spring boot默认已经集成了logging,同时也是默认开启的,如果想根据自己的需求对日志进行配置,方法很简单--只需要在配置文件中进行相应设置,这里提供我自己的配置如 ...

  10. docker 自定义镜像

    step1:自定义镜像 原镜像 registry.aspider.avlyun.org/library/php-apache docker run -d --name xz_apache regist ...