验证中...
Languages: Python
Categories: 常用工具包
Latest update 2019-08-22 15:30
gistfile1.txt
Raw Copy
import requests
url = 'https://www.lagou.com/jobs/positionAjax.json?px=default&needAddtionalResult=false';
data ={
'first':'False',
'pn':'1',
'kd':'php',
# 'sid':'11274af38a1a4c348e43da80a965e3d9'
};
data['kd'] = input('请输入职位:');
print(data['kd']);
headers={
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding':'gzip, deflate, br',
'Accept-Language':'zh-CN,zh;q=0.9',
'Connection':'keep-alive',
'Content-Length':'60',
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'JSESSIONID=ABAAABAAAIAACBIB3BF19C0968FD8E46E502C48403468C4; WEBTJ-ID=20190822143914-16cb80cfe22e5-06de660ec6ce2f-417c4e11-2073600-16cb80cfe231ef; _ga=GA1.2.1284766315.1566455955; _gid=GA1.2.1178678031.1566455955; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1566455955; user_trace_token=20190822143911-8cfe691b-c4a7-11e9-a503-5254005c3644; LGSID=20190822143911-8cfe6c2e-c4a7-11e9-a503-5254005c3644; LGUID=20190822143911-8cfe6ed5-c4a7-11e9-a503-5254005c3644; index_location_city=%E5%85%A8%E5%9B%BD; TG-TRACK-CODE=index_navigation; SEARCH_ID=c44ef0edfd4446cea533b38d2ef35bfc; X_HTTP_TOKEN=b85253e9b901843985185466511cc38edf18b81b1c; _gat=1; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1566458163; LGRID=20190822151558-b0993858-c4ac-11e9-8b54-525400f775ce',
'Host':'www.lagou.com',
'Origin':'https://www.lagou.com',
'Referer':'https://www.lagou.com/jobs/list_PHP?px=default&city=%E5%85%A8%E5%9B%BD',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6788.400 QQBrowser/10.3.2843.400',
'X-Anit-Forge-Code':'0',
'X-Anit-Forge-Token':'None',
'X-Requested-With':'XMLHttpRequest',
}
re = requests.post(url,data=data,headers=headers)
re_json = re.json();
print(re_json);
result = re_json['content']['positionResult']['result']
for dat in result:
# print(dat)
datajson = f"{dat['positionName']},{dat['workYear']},{dat['education']},{dat['salary']},{dat['city']}"
print(datajson)
with open('./tt.csv','a') as of:
of.write(datajson+'\n')

Comment list( 0 )

You need to Sign in for post a comment

Help Search