猎聘网站搜索大数据关键字,只能显示100页,爬取这一百页的相关信息,以便做分析。

__author__ = 'Fred Zhao'

import requests
from bs4 import BeautifulSoup
import os
import csv class JobSearch(): def __init__(self):
self.headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'}
self.base_url = 'https://www.liepin.com/zhaopin/?ckid=c1a868fa8b83aa5b&fromSearchBtn=2&init=-1&sfrom=click-pc_homepage-centre_searchbox-search_new&degradeFlag=0&key=大数据&headckid=c1a868fa8b83aa5b&d_pageSize=40&siTag=LGV-fc5u_67LtFjetF6ACg~fA9rXquZc5IkJpXC-Ycixw&d_headId=8e7325814e7ed9919787ee3fe85e1c94&d_ckId=8e7325814e7ed9919787ee3fe85e1c94&d_sfrom=search_fp&d_curPage=99&curPage='
self.base_path = os.path.dirname(__file__) def makedir(self, name):
path = os.path.join(self.base_path, name)
isExist = os.path.exists(path)
if not isExist:
os.makedirs(path)
print("File has been created.")
else:
print('OK!The file is existed. You do not need create a new one.')
os.chdir(path) def request(self, url):
r = requests.get(url, headers=self.headers)
return r def get_detail(self, page):
r = self.request(self.base_url + page)
ul = BeautifulSoup(r.text, 'lxml').find('ul', class_='sojob-list')
plist = ul.find_all('li')
self.makedir('job_data')
rows = []
for item in plist:
job_info = item.find('div', class_='sojob-item-main clearfix').find('div', class_='job-info')
position = job_info.find('h3').get('title')
print(position)
job_info_list = job_info.find_all('p')
job_condition = job_info_list[0].get('title')
print(job_condition)
job_time = job_info_list[1].find('time').get('title')
print(job_time)
company_info = item.find('div', class_='sojob-item-main clearfix').find('div', class_='company-info')
company = company_info.find('p', class_='company-name').find('a').get('title')
print(company) rows.append([position, job_condition, job_time, company])
self.save_to_csv(rows) def save_to_csv(self, rows):
with open('job.csv', 'a') as f:
writer = csv.writer(f)
writer.writerows(rows) if __name__ == '__main__':
job = JobSearch()
for page in range(0, 100):
job.get_detail(str(page))

爬取猎聘大数据岗位相关信息--Python的更多相关文章

  1. 利用python爬取58同城简历数据

    利用python爬取58同城简历数据 利用python爬取58同城简历数据 最近接到一个工作,需要获取58同城上面的简历信息(http://gz.58.com/qzyewu/).最开始想到是用pyth ...

  2. 使用Selenium爬取网站表格类数据

    本文转载自一下网站:Python爬虫(5):Selenium 爬取东方财富网股票财务报表 https://www.makcyun.top/web_scraping_withpython5.html 需 ...

  3. 基于爬取百合网的数据,用matplotlib生成图表

    爬取百合网的数据链接:http://www.cnblogs.com/YuWeiXiF/p/8439552.html 总共爬了22779条数据.第一次接触matplotlib库,以下代码参考了matpl ...

  4. Python——爬取百度百科关键词1000个相关网页

    Python简单爬虫——爬取百度百科关键词1000个相关网页——标题和简介 网站爬虫由浅入深:慢慢来 分析: 链接的URL分析: 数据格式: 爬虫基本架构模型: 本爬虫架构: 源代码: # codin ...

  5. 16、爬取知乎大v张佳玮的文章“标题”、“摘要”、“链接”,并存储到本地文件

    爬取知乎大v张佳玮的文章“标题”.“摘要”.“链接”,并存储到本地文件 # 爬取知乎大v张佳玮的文章“标题”.“摘要”.“链接”,并存储到本地文件 # URL https://www.zhihu.co ...

  6. Scrapy实战篇(八)之Scrapy对接selenium爬取京东商城商品数据

    本篇目标:我们以爬取京东商城商品数据为例,展示Scrapy框架对接selenium爬取京东商城商品数据. 背景: 京东商城页面为js动态加载页面,直接使用request请求,无法得到我们想要的商品数据 ...

  7. jsoup爬取某网站安全数据

    jsoup爬取某网站安全数据 package com.vfsd.net; import java.io.IOException; import java.sql.SQLException; impor ...

  8. 手把手教你使用Python爬取西刺代理数据(下篇)

    /1 前言/ 前几天小编发布了手把手教你使用Python爬取西次代理数据(上篇),木有赶上车的小伙伴,可以戳进去看看.今天小编带大家进行网页结构的分析以及网页数据的提取,具体步骤如下. /2 首页分析 ...

  9. 爬虫黑科技,我是怎么爬取indeed的职位数据的

    最近在学习nodejs爬虫技术,学了request模块,所以想着写一个自己的爬虫项目,研究了半天,最后选定indeed作为目标网站,通过爬取indeed的职位数据,然后开发一个自己的职位搜索引擎,目前 ...

随机推荐

  1. vue数据渲染、条件判断及列表循环

    1.数据渲染  {{msg}} <template> <div id="app"> {{msg}} </div> </template&g ...

  2. MySQL常用的一些语句,索引,字段等

    1.库相关:建库:character set:指定编码COLLATE:排序规则 utf8mb4_general_ci 大小写不敏感CREATE DATABASE `test_db` default c ...

  3. error C2664: “ATL::CStringT<BaseType,StringTraits>::Remove”: 不能将参数 1 从“const char [2]”转换为“char”

    转自VC错误:http://www.vcerror.com/?p=1395 问题描述: 代码: CString str("asdfafda"); str.Remove(" ...

  4. linux超级块和inode 详解 和 df 、du 命令详解与环境变量

    一.inode块,Unix文件的核心. 首先需要明白的是,在Unix操作系统中的任何资源都被当作文件来管理.如目录.光驱.终端设备等等,都被当作是一种文件.从这方面来说,Unix操作系统中的所有的目录 ...

  5. 20150721—HTML的定位 JS (转)

    本文转载于:http://blog.csdn.net/xuantian868/article/details/3116442   HTML:scrollLeft,scrollWidth,clientW ...

  6. getAttribute 与getParmeter 区别

    1.getAttribute是取得jsp中 用setAttribute設定的attribute 2.parameter得到的是string:attribute得到的是object 3.request. ...

  7. ZwQueryDirectoryFile用法

    1. 当返回值为STATUS_SUCCESS时,返回的字节数保存在IoStatusBlock.Information字段中: 2. 如果FileName字段被指定了,那么对于同时指定的FileHand ...

  8. js日历算法

    页面 <div class="un1"> <h2>服务档期</h2> <div class="date-panel" ...

  9. 怎么追加byte内容

    public byte[] InsertByte(string dx) { List<byte> temp = new List<byte>(); byte[] b= Enco ...

  10. 推荐系统之隐语义模型LFM

    LFM(latent factor model)隐语义模型,这也是在推荐系统中应用相当普遍的一种模型.那这种模型跟ItemCF或UserCF的不同在于: 对于UserCF,我们可以先计算和目标用户兴趣 ...