Python爬取智聯(lián)招聘數(shù)據(jù)分析師崗位相關(guān)信息的方法
進入智聯(lián)招聘官網(wǎng),在搜索界面輸入‘數(shù)據(jù)分析師',界面跳轉(zhuǎn),按F12查看網(wǎng)頁源碼,點擊network

選中XHR,然后刷新網(wǎng)頁

可以看到一些Ajax請求, 找到畫紅線的XHR文件,點擊可以看到網(wǎng)頁的一些信息



在Header中有Request URL,我們需要通過找尋Request URL的特點來構(gòu)造這個請求網(wǎng)址,
點擊Preview,可以看到我們所需要的信息就存在result中,這信息基本是json格式,有些是列表;
下面我們通過Python爬蟲來爬取上面的信息;
代碼如下:
import requests
from urllib.parse import urlencode
import json
#from requests import codes
#import os
#from hashlib import md5
#from multiprocessing.pool import Pool
#import re
def get_page(offset):
params = {
'start': offset,
'pageSize': '90',
'cityId': '530',
'salary': '0,0',
'workExperience': '-1',
'education': '-1',
'companyType': '-1',
'employmentType': '-1',
'jobWelfareTag': '-1',
'kw': '數(shù)據(jù)分析師',
'kt': '3',
'_v': '0.77091902',
'x-zp-page-request-id': '8ff0aa73bf834b408f46324e44d89b84-1562722989022-210101',
'x-zp-client-id': '2dc4c9a4-e80d-4488-84a3-03426dd69a1e'
}
base_url = 'https://fe-api.zhaopin.com/c/i/sou?'
url = base_url + urlencode(params)
try:
resp = requests.get(url)
print(url)
if 200 == resp.status_code:
print(resp.json())
return resp.json()
except requests.ConnectionError:
return None
def get_information(json_page):
if json_page.get('data'):
results = json_page.get('data').get('results')
for result in results:
yield {
'city': result.get('city').get('display'),
'company': result.get('company').get('name'),
#'welfare':result.get('welfare'),
'workingExp':result.get('workingExp').get('name'),
'salary':result.get('salary'),
'eduLevel':result.get('eduLevel').get('name')
}
print('succ')
def write_to_file(content):
with open('result.txt','a',encoding='utf-8') as f:
print(type(json.dumps(content)))
f.write(json.dumps(content,ensure_ascii=False)+'\n')
def main(offset):
json_page=get_page(offset)
for content in get_information(json_page):
write_to_file(content)
if __name__=='__main__':
for i in range(10):
main(offset=90*i)
爬取結(jié)果如下:

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- 一個簡單的python爬蟲程序 爬取豆瓣熱度Top100以內(nèi)的電影信息
- Python爬蟲——爬取豆瓣電影Top250代碼實例
- Python利用lxml模塊爬取豆瓣讀書排行榜的方法與分析
- python requests庫爬取豆瓣電視劇數(shù)據(jù)并保存到本地詳解
- Python使用mongodb保存爬取豆瓣電影的數(shù)據(jù)過程解析
- Python使用Beautiful Soup爬取豆瓣音樂排行榜過程解析
- python使用requests模塊實現(xiàn)爬取電影天堂最新電影信息
- python3 實現(xiàn)爬取TOP500的音樂信息并存儲到mongoDB數(shù)據(jù)庫中
- python爬蟲 爬取58同城上所有城市的租房信息詳解
- Python實現(xiàn)的爬取豆瓣電影信息功能案例
相關(guān)文章
pymongo為mongodb數(shù)據(jù)庫添加索引的方法
這篇文章主要介紹了pymongo為mongodb數(shù)據(jù)庫添加索引的方法,涉及Python操作mongodb數(shù)據(jù)庫的相關(guān)技巧,非常簡單實用,需要的朋友可以參考下2015-05-05
Django模板標簽{% for %}循環(huán),獲取制定條數(shù)據(jù)實例
這篇文章主要介紹了Django模板標簽{% for %}循環(huán),獲取制定條數(shù)據(jù)實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
python3 破解 geetest(極驗)的滑塊驗證碼功能
這篇文章主要介紹了python3 破解 geetest(極驗)的滑塊驗證碼功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2018-02-02
python使用collections模塊的容器數(shù)據(jù)類型高效處理數(shù)據(jù)
這篇文章主要為大家介紹了python使用collections模塊的容器數(shù)據(jù)類型高效處理數(shù)據(jù)的方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-06-06

