"""通过接口测试的技术获取某招聘网平台的资料"""
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. ZOJ 3329 期望DP

    题目大意: 给定3个已经规定好k1,k2,k3面的3个色子,如果扔到a,b,c则重新开始从1 计数,否则不断叠加所有面的数字之和,直到超过n,输出丢的次数的数学期望 我们在此令dp[]数组记录从当前数 ...

  2. C#高级编程第9版 第一章 .NET体系结构 读后笔记

    .NET的CLR把源代码编译为IL,然后又把IL编译为平台专用代码. IL总是即时编译的,这一点的理解上虽然明白.当用户操作C#开发的软件时,应该是操作已经编译好的程序.那么此时安装在客户机上的程序是 ...

  3. POJ 2411_Mondriaan's Dream

    题意: 用1*2和2*1的方块将给定长宽的矩形填满.问有多少种放法,对称的算两种. 分析: 状态压缩dp 首先用0表示前一行没有竖块占用这个位置,而1表示该位置和他上方的位置放了一个竖块,从而压缩状态 ...

  4. [bzoj2946][Poi2000]公共串_后缀数组_二分

    公共串 bzoj-2946 Poi-2000 题目大意:给定$n$个字符串,求他们的最长公共子串. 注释:$1\le n\le 5$,$1\le minlen<maxlen\le 2000$. ...

  5. 使用Post方法模拟登陆爬取网页(转)

    使用Post方法模拟登陆爬取网页   最近弄爬虫,遇到的一个问题就是如何使用post方法模拟登陆爬取网页.下面是极简版的代码: import java.io.BufferedReader; impor ...

  6. delphi异步选择模型编程TCP

    Server端: unit U_FrmServer; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, ...

  7. import与require的区别

    载入一个模块import() 与 require() 功能相同,但具有一定程度的自动化特性.假设我们有如下的目录结构:~~~app/app/classes/app/classes/MyClass.lu ...

  8. Effective C++ Item 41 了解隐式接口和编译期多态

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie 经验:class 和 templates 都支持接口和多态. 对 classes 而言接口是 ...

  9. HDU 3280 Equal Sum Partitions(二分查找)

    Equal Sum Partitions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  10. UVa10048_Audiophobia(最短路/floyd)(小白书图论专题)

    解题报告 题意: 求全部路中最大分贝最小的路. 思路: 类似floyd算法的思想.u->v能够有另外一点k.通过u->k->v来走,拿u->k和k->v的最大值和u-&g ...