本文来源吾爱破解论坛
话不多说,看代码:
[Python] 纯文本查看 复制代码
import re,requests,json chengshi=input("请输入工作城市:") mingcheng=input("请输入工作名称:") url='https://www.lagou.com/jobs/positionAjax.json?px=default&city=%s&needAddtionalResult=false'%chengshi headers = { 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Cookie': 'WEBTJ-ID=20180918181741-165ec2f83d743-0ee41db9c69e0e-6e1f147a-2073600-165ec2f83d95d1; _ga=GA1.2.1559975793.1537265862; ' 'user_trace_token=20180918181742-13d9fe9b-bb2c-11e8-baf2-5254005c3644; LGUID=20180918181742-13da0831-bb2c-11e8-baf2-5254005c3644; ' 'JSESSIONID=ABAAABAAAFCAAEG0FCA6542C1D06F1F470B0A7189B8AD06; index_location_city=%E6%88%90%E9%83%BD; ' 'TG-TRACK-CODE=index_search; _gid=GA1.2.1437892044.1537705170; LGSID=20180923201929-eb4f9cfb-bf2a-11e8-bb56-5254005c3644;' ' PRE_UTM=; PRE_HOST=www.baidu.com; PRE_SITE=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DXpamso_IxFbfBezXbGYWv8-vI3sYyGf67_89jrtjXQK%26wd%3D%26eqid%3Da27f010200061c48000000025ba784cc;' ' PRE_LAND=https%3A%2F%2Fwww.lagou.com%2F; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1537265862,1537265872,1537354446,1537705170; ' 'LGRID=20180923201940-f1eea38b-bf2a-11e8-bb56-5254005c3644; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1537705181; SEARCH_ID=baf28c394763403c8afc3fc36dce76a4', 'Host': 'www.lagou.com', 'Origin': 'https://www.lagou.com', 'Referer': 'https://www.lagou.com/jobs/list_python?isSchoolJob=1', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'X-Anit-Forge-Code': '0','X-Anit-Forge-Token': 'None', 'X-Requested-With': 'XMLHttpRequest', } num=0 bar=0 while num<100: num=num+1 date={'first':'true','kd':'%s'%mingcheng,'pn':num} returned=requests.post(url,date,headers=headers) html=json.loads(returned.text.strip('()[]')) html=html['content'] html=html['positionResult'] n=int(html['resultSize']) if n>0: html=html['result'] for i in html: bar = bar + 1 dianhua = i["lastLogin"] # 电话 xueli = i["education"] # 学历要求 gongzi = i["salary"] # 工资 gongsimingcheng = i["companyFullName"] # 公司名称 fuli = i["positionAdvantage"] # 公司福利 gongzuo = i["skillLables"] # 工作 chengshi = i["city"] # 城市 print("城市:%s---公司名称:%s---学历要求:%s---工作:%s---工资:%s---福利:%s---联系电话:%s" % (chengshi, gongsimingcheng, xueli, gongzuo, gongzi, fuli, dianhua)) else: print("成功爬取了%s条招聘信息"%bar) break
1.jpg (373.09 KB, 下载次数: 1)
下载附件 保存到相册
2018-9-24 14:43 上传
版权声明:
本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。
- 上一篇: 被诅咒的房子 《逃出事故物件》8月将和玩家见面
- 下一篇: python爬虫之爬取美女图片