• python实现对某招聘网接口测试获取平台信息


    """通过接口测试的技术获取某招聘网平台的资料"""
    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()
  • 相关阅读:
    最新Navicat Premium12 破解方法,亲测可用
    (转)Navicat_12安装与破解激活,注册机亲测可用
    使用ApiPost模拟发送get、post、delete、put等http请求
    模拟POST、Get 请求的工具----APIpost(中文版POSTMAN)
    推荐一款接口文档生成工具,apipost,好用
    作为后端开发者,如何更优雅、便捷的生成接口文档?
    使用apipost调试api接口并快速生成接口文档的一些小技巧,比postman更好用
    中文版postman——apipost,不试一下,你就不知道它有多香
    ApiPost如何在预执行脚本里添加请求参数?
    ApiPost的预执行脚本和后执行脚本
  • 原文地址:https://www.cnblogs.com/Teachertao/p/10426440.html
Copyright © 2020-2023  润新知