python3 requests 获取 拉勾工作数据

 #-*- coding:utf-8 -*-
__author__ = "carry" import requests,json for x in range(1, 15):
url ='http://www.lagou.com/jobs/positionAjax.json'
#proxies = {"http":"http://125.105.17.229:808"}
headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
payload = {"city":"杭州", "district":"西湖区", "needAddtionalResult":"false", "first":"true", "pn":x, "kd":"测试"}
result = requests.post(url,data=payload,headers=headers)
#result = requests.post(url,data=payload,proxies=proxies)
result_json = result.json()
print(result_json) l = result_json["content"]["positionResult"]["result"]
for x in l:
s = "岗位名称:%s,公司名:%s,业务:%s,工作年限:%s,工资:%s" \
% (x["positionName"],x["companyFullName"],x["industryField"],x["workYear"],x["salary"]) with open("D:\\lagou.txt", "a+", encoding="utf-8") as f:
f.write(s)
f.write("\n")
上一篇:关于在eclipse上部署Tomcat时出现8080等端口被占用问题的解决方法


下一篇:Eclipse中使用tomcat 8服务器初级教程