"""通过接口测试的技术获取某招聘网平台的资料"""
url = "https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false"
def getHeaders():
headers = {
"Content-Type": "application/json;charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
"Cookie": "JSESSIONID=ABAAABAAAIAACBI2438D04CF91400F1FF0A2B38358AFFA5; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1550930753; _ga=GA1.2.193872554.1550930753; _gat=1; user_trace_token=20190223220617-301cdfdc-3774-11e9-af96-525400f775ce; LGSID=20190223220617-301ce139-3774-11e9-af96-525400f775ce; PRE_UTM=; PRE_HOST=cn.bing.com; PRE_SITE=https%3A%2F%2Fcn.bing.com%2F; PRE_LAND=https%3A%2F%2Fwww.lagou.com%2F; LGUID=20190223220617-301ce2a8-3774-11e9-af96-525400f775ce; _gid=GA1.2.1796885419.1550930753; index_location_city=%E5%85%A8%E5%9B%BD; SEARCH_ID=a0ad1593bd14438d8a205a17a17f95c1; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1550930826; LGRID=20190223220730-5b9c7593-3774-11e9-af96-525400f775ce; TG-TRACK-CODE=search_code",
"Referer": "https://www.lagou.com/jobs/list_%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E5%B7%A5%E7%A8%8B%E5%B8%88?labelWords=&fromSearch=true&suginput="
}
return headers def lagou(page=2):
positions = []
r = requests.post(
url=url,
headers=getHeaders(),
data={"first": False,"pn": page,"kd": "自动化测试工程师"})
text = r.text
print(text)
for i in range(0,15):
city = r.json()#["content"]["positionResult"]["result"][i]["city"]
print(city)
positionAdvantage = r.json()["content"]["positionResult"]["result"][i]["positionAdvantage"]
workYear = r.json()["content"]["positionResult"]["result"][i]["workYear"]
companyFullName = r.json()["content"]["positionResult"]["result"][i]["companyFullName"]
education = r.json()["content"]["positionResult"]["result"][i]["education"]
district = r.json()["content"]["positionResult"]["result"][i]["district"]
salary = r.json()["content"]["positionResult"]["result"][i]["salary"]
companySize = r.json()["content"]["positionResult"]["result"][i]["companySize"]
companyLabelList = r.json()["content"]["positionResult"]["result"][i]["companyLabelList"]
positionLables = r.json()["content"]["positionResult"]["result"][i]["positionLables"]
position = {
"城市":city,
"区域":district,
"学历":education,
"工作年限":workYear,
"薪资":salary,
"公司名称":companyFullName,
"公司大小":companySize,
"公司标签":companyLabelList,
"工作标签":positionLables,
"公司福利":positionAdvantage
}
positions.append(position)
return positions
lagou()
def writeCsv():
headers = ["城市", "区域", "学历", "工作年限", "薪资", "公司名称", "公司大小", "公司标签", "工作标签","公司福利"]
for item in range(1,31):
positions = lagou(page=item)
with open("lagou.cvs","a") as f:
writer = csv.DictWriter(f,headers)
writer.writeheader()
writer.writerows(positions) writeCsv()

python实现对某招聘网接口测试获取平台信息的更多相关文章

  1. python类的继承和多态,获取对象信息

    继承 类的继承机制使得子类可以继承父类中定义的方法,拥有父类的财产,比如有一个Animal的类作为父类,它有一个eat方法: class Animal(object): def __init__(se ...

  2. Python爬取猪肉价格网并获取Json数据

    场景 猪肉价格网站: http://zhujia.zhuwang.cc/ 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获 ...

  3. 网络爬虫之scrapy爬取某招聘网手机APP发布信息

    1 引言 过段时间要开始找新工作了,爬取一些岗位信息来分析一下吧.目前主流的招聘网站包括前程无忧.智联.BOSS直聘.拉勾等等.有段时间时间没爬取手机APP了,这次写一个爬虫爬取前程无忧手机APP岗位 ...

  4. python使用unittest模块selenium访问斗鱼获取直播信息

    import unittest from selenium import webdriver from bs4 import BeautifulSoup as bs class douyu(unitt ...

  5. Scrapy实现腾讯招聘网信息爬取【Python】

    一.腾讯招聘网 二.代码实现 1.spider爬虫 # -*- coding: utf-8 -*- import scrapy from Tencent.items import TencentIte ...

  6. 利用xpath爬取招聘网的招聘信息

    爬取招聘网的招聘信息: import json import random import time import pymongo import re import pandas as pd impor ...

  7. Python基础:获取平台相关信息

    Windows 10家庭中文版,Python 3.6.4, 本文介绍了使用os.platform.sys三个模块获取Python程序的运行平台相关的信息. os模块:提供 各种各样的操作系统接口 os ...

  8. [Python爬虫] 之一 : Selenium+Phantomjs动态获取网站数据信息

    本人刚才开始学习爬虫,从网上查询资料,写了一个利用Selenium+Phantomjs动态获取网站数据信息的例子,当然首先要安装Selenium+Phantomjs,具体的看 http://www.c ...

  9. python 学习笔记 12 -- 写一个脚本获取城市天气信息

    近期在玩树莓派,前面写过一篇在树莓派上使用1602液晶显示屏,那么可以显示后最重要的就是显示什么的问题了. 最easy想到的就是显示时间啊,CPU利用率啊.IP地址之类的.那么我认为呢,假设可以显示当 ...

随机推荐

  1. java 构造不可变类集的使用方法

    首先用到的就是Collections.unmodifiablexxx(         set.add("hello");         set.add("insert ...

  2. poj 1456

    #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 10010 #define in ...

  3. 搜索 比MySQL快10倍?这可能是目前AWS Aurora最详解读!

    作者介绍 朱阅岸,中国人民大学博士,现供职于腾讯云数据库团队.研究方向主要为数据库系统理论与实现.新硬件平台下的数据库系统以及TP+AP型混合系统.   编者按 Aurora作为AWS云上的关系数据库 ...

  4. android开发里跳过的坑——调用已安装视频播放器在有些机器上无效

    调用已安装视频播放器播放未修改之前的代码 private void startPlay(String fileName){ File file = new File(fileName); Intent ...

  5. 从零开始写STL—栈和队列

    从零开始写STL-栈和队列 适配器模式 意图:将一个类的接口转换成客户希望的另外一个接口.适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 主要解决:主要解决在软件系统中,常常要将 ...

  6. 1076. Forwards on Weibo (30)【树+搜索】——PAT (Advanced Level) Practise

    题目信息 1076. Forwards on Weibo (30) 时间限制3000 ms 内存限制65536 kB 代码长度限制16000 B Weibo is known as the Chine ...

  7. Ubuntu14.04 忘记rootpassword的解决方法

    对于windows操作系统,假设忘记管理员password,事实上还是蛮好解决的. 最简单的一种方式就是使用PE--电脑店,老毛桃等等,都能够非常完美的解决问题. 假设是Linux操作系统的话.事实上 ...

  8. yarn-cli 缓存

    yarn cache list Yarn 会在你的用户目录下开辟一块全局缓存用以保存下载的包.yarn cache list 用于列出所有已经缓存的包. yarn cache dir 执行 yarn ...

  9. Oracle442个应用场景---------PL/SQL基础

    ----------------------------------------------------------------------------------- 备份和恢复数据库略过.在后面解说 ...

  10. ≪统计学习精要(The Elements of Statistical Learning)≫课堂笔记(三)

    照例文章第一段跑题,先附上个段子(转载的哦~): I hate CS people. They don't know linear algebra but want to teach projecti ...