"""通过接口测试的技术获取某招聘网平台的资料"""
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中检测-在运行时指定对象是否是特定类的一个实例---关键字 instanceof

    java 中的instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例.instanceof通过返回一个布尔值来指出,这个对象是否是这个特定类或者是它的子类的一个实例. if(requ ...

  2. 九度oj 题目1181:遍历链表

    题目1181:遍历链表 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3483 解决:1465 题目描述: 建立一个升序链表并遍历输出. 输入: 输入的每个案例中第一行包括1个整数:n(1 ...

  3. POJ 3468_A Simple Problem with Integers(树状数组)

    完全不知道该怎么用,看书稍微懂了点. 题意: 给定序列及操作,求区间和. 分析: 树状数组可以高效的求出连续一段元素之和或更新单个元素的值.但是无法高效的给某一个区间的所有元素同时加个值. 不能直接用 ...

  4. Eclipse替换find/Replace

    使用快捷键:ctrl+F       replaceAll

  5. AtCoder Grand Contest 012 B Splatter Painting(记忆化搜索)

    题意: 给一个包含N个顶点,M条边,无自环和重边的简单无向图,初始每个点颜色都为0,每条边的长度为1,连接着ai,bi两个节点.经过若干个操作, 每次将与某个点vi距离不超过di的所有点染成某种颜色c ...

  6. LOAP& its implimenlation

    LDAP 概念 LDAP的英文全称是Lightweight Directory Access Protocol,简称为LDAP,LDAP是轻量目录访问协议,LDAP是轻量目录访问协议.简单的说来,LD ...

  7. Redis集群方案收集

    说明: 如果不考虑客户端分片去实现集群,那么市面上基本可以说就三种方案最成熟,它们分别如下所示: 系统 贡献者 是否官方Redis实现 编程语言 Twemproxy Twitter 是 C Redis ...

  8. JDBC的Statement对象

    以下内容引用自http://wiki.jikexueyuan.com/project/jdbc/statements.html: 一旦获得了数据库的连接,就可以和数据库进行交互.JDBC的Statem ...

  9. hdu 4864 Task(贪心)

    pid=4864">http://acm.hdu.edu.cn/showproblem.php?pid=4864 大致题意:有n台机器和m个任务,都有两个參数工作时间time和难度le ...

  10. C#.NEt-GDI+中的Pen測试

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...