python 爬虫系列03--职位爬虫
职位爬虫
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--职位爬虫的更多相关文章
- 【网络爬虫入门03】爬虫解析利器beautifulSoup模块的基本应用
[网络爬虫入门03]爬虫解析利器beautifulSoup模块的基本应用 1.引言 网络爬虫最终的目的就是过滤选取网络信息,因此最重要的就是解析器了,其性能的优劣直接决定这网络爬虫的速度和效率.B ...
- java爬虫系列第一讲-爬虫入门
1. 概述 java爬虫系列包含哪些内容? java爬虫框架webmgic入门 使用webmgic爬取 http://ady01.com 中的电影资源(动作电影列表页.电影下载地址等信息) 使用web ...
- python爬虫系列之初识爬虫
前言 我们这里主要是利用requests模块和bs4模块进行简单的爬虫的讲解,让大家可以对爬虫有了初步的认识,我们通过爬几个简单网站,让大家循序渐进的掌握爬虫的基础知识,做网络爬虫还是需要基本的前端的 ...
- python 爬虫系列07-天气爬虫
看天气 import requests from bs4 import BeautifulSoup ALL_DATA = [] def parse_page(url): headers = { 'Us ...
- Python3爬虫系列:理论+实验+爬取妹子图实战
Github: https://github.com/wangy8961/python3-concurrency-pics-02 ,欢迎star 爬虫系列: (1) 理论 Python3爬虫系列01 ...
- 爬虫系列(三) urllib的基本使用
一.urllib 简介 urllib 是 Python3 中自带的 HTTP 请求库,无需复杂的安装过程即可正常使用,十分适合爬虫入门 urllib 中包含四个模块,分别是 request:请求处理模 ...
- 爬虫系列(九) xpath的基本使用
一.xpath 简介 究竟什么是 xpath 呢?简单来说,xpath 就是一种在 XML 文档中查找信息的语言 而 XML 文档就是由一系列节点构成的树,例如,下面是一份简单的 XML 文档: &l ...
- 爬虫系列(五) re的基本使用
1.简介 究竟什么是正则表达式 (Regular Expression) 呢?可以用下面的一句话简单概括: 正则表达式是一组特殊的 字符序列,由一些事先定义好的字符以及这些字符的组合形成,常常用于 匹 ...
- 爬虫系列(七) requests的基本使用
一.requests 简介 requests 是一个功能强大.简单易用的 HTTP 请求库,可以使用 pip install requests 命令进行安装 下面我们将会介绍 requests 中常用 ...
随机推荐
- OpenSSH/PuTTY/SSH使用
OpenSSH/PuTTY/SSH 常用SSH服务指令 ① 启动SSH服务的命令 service sshd start ② 停止SSH服务的命令 service sshd stop ③ 重新启动SSH ...
- ArcGIS Desktop和Engine中对点要素图层Graduated Symbols渲染的实现 Rotation Symbol (转)
摘要 ArcGIS中,对于要素图层的渲染,支持按照要素字段的值渲染要素的大小,其中Graduated Symbols可以对大小进行分级渲染.在个人开发系统的过程中,也可以用来美化数据显 ...
- [raspberry p3] suse wifi驱动加载
问题 raspberry pi3安装后发现wifi 启动不了, brcmf_sdio加载失败了,return error code为-110 处理方法 打开 /etc/dracut.conf.d/ra ...
- Eclipse下的Hadoop应用开发准备
window下开发的准备: A.在windows的某个目录下解压一个hadoop的安装包 B.将安装包下的lib和bin目录用对应windows版本平台编译的本地库替换 C.在window系统中配置H ...
- 多线程《七》信号量,Event,定时器
一 信号量 信号量也是一把锁,可以指定信号量为5,对比互斥锁同一时间只能有一个任务抢到锁去执行,信号量同一时间可以有5个任务拿到锁去执行,如果说互斥锁是合租房屋的人去抢一个厕所,那么信号量就相当于一群 ...
- Java面向对象之关键字this 入门实例
一.基础概念 1.关键字this是指:哪个对象调用this所在的函数.this就指向当前这个对象. 2.用法: (1).this关键字可以解决:构造函数私有化问题. 注意:构造函数只能被构造函数调用, ...
- Reviewing notes 1.1 of Analytic geometry
Chapter 1 Vector Algebra ♦ Vector Space Vector and vector space A vector is described as a quantity ...
- [USACO07DEC]泥水坑Mud Puddles BFS BZOJ 1627
题目描述 Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the ...
- springcloud微服务config的使用
首先需要建立一个server端: pom依赖中加入 <dependency> <groupId>org.springframework.cloud</groupId> ...
- jquery实现下拉菜单
需要实现的效果如图: <!DOCTYPE html> <html> <head lang="en"> <meta charset=&quo ...