python3 requests 获取 拉勾工作数据

 1 #-*- coding:utf-8 -*-
 2 __author__ = "carry"
 3 
 4 import requests,json
 5 
 6 for x in range(1, 15):
 7     url ='http://www.lagou.com/jobs/positionAjax.json'
 8     #proxies = {"http":"http://125.105.17.229:808"}
 9     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'}
10     payload = {"city":"杭州", "district":"西湖区", "needAddtionalResult":"false", "first":"true", "pn":x, "kd":"测试"}
11     result = requests.post(url,data=payload,headers=headers)
12     #result = requests.post(url,data=payload,proxies=proxies)
13     result_json = result.json()
14     print(result_json)
15 
16     l = result_json["content"]["positionResult"]["result"]
17     for x in l:
18         s = "岗位名称:%s,公司名:%s,业务:%s,工作年限:%s,工资:%s" \
19         % (x["positionName"],x["companyFullName"],x["industryField"],x["workYear"],x["salary"])
20 
21         with open("D:\\lagou.txt", "a+", encoding="utf-8") as f:
22             f.write(s)
23             f.write("\n")

 

转载于:https://www.cnblogs.com/lxs1314/p/7113509.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值