python实现对某招聘网接口测试获取平台信息
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python实现对某招聘网接口测试获取平台信息,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3169字,纯文字阅读大概需要5分钟。
内容图文
![python实现对某招聘网接口测试获取平台信息](/upload/InfoBanner/zyjiaocheng/840/30677dd781cb42338d08bd37ff0d0842.jpg)
"""通过接口测试的技术获取某招聘网平台的资料"""
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实现对某招聘网接口测试获取平台信息全部内容,希望文章能够帮你解决python实现对某招聘网接口测试获取平台信息所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。