Python爬取智聯(lián)招聘數(shù)據(jù)分析師崗位相關(guān)信息的方法
進(jìn)入智聯(lián)招聘官網(wǎng),在搜索界面輸入‘?dāng)?shù)據(jù)分析師',界面跳轉(zhuǎn),按F12查看網(wǎng)頁源碼,點(diǎn)擊network
選中XHR,然后刷新網(wǎng)頁
可以看到一些Ajax請(qǐng)求, 找到畫紅線的XHR文件,點(diǎn)擊可以看到網(wǎng)頁的一些信息
在Header中有Request URL,我們需要通過找尋Request URL的特點(diǎn)來構(gòu)造這個(gè)請(qǐng)求網(wǎng)址,
點(diǎn)擊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é)果如下:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 一個(gè)簡(jiǎn)單的python爬蟲程序 爬取豆瓣熱度Top100以內(nèi)的電影信息
- Python爬蟲——爬取豆瓣電影Top250代碼實(shí)例
- Python利用lxml模塊爬取豆瓣讀書排行榜的方法與分析
- python requests庫爬取豆瓣電視劇數(shù)據(jù)并保存到本地詳解
- Python使用mongodb保存爬取豆瓣電影的數(shù)據(jù)過程解析
- Python使用Beautiful Soup爬取豆瓣音樂排行榜過程解析
- python使用requests模塊實(shí)現(xiàn)爬取電影天堂最新電影信息
- python3 實(shí)現(xiàn)爬取TOP500的音樂信息并存儲(chǔ)到mongoDB數(shù)據(jù)庫中
- python爬蟲 爬取58同城上所有城市的租房信息詳解
- Python實(shí)現(xiàn)的爬取豆瓣電影信息功能案例
相關(guān)文章
終端命令查看TensorFlow版本號(hào)及路徑的方法
今天小編就為大家分享一篇終端命令查看TensorFlow版本號(hào)及路徑的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-06-06python全棧要學(xué)什么 python全棧學(xué)習(xí)路線
在本文中小編給大家整理了關(guān)于python全棧要學(xué)什么以及python全棧學(xué)習(xí)路線的知識(shí)點(diǎn)內(nèi)容,需要的朋友們參考下。2019-06-06python將xml xsl文件生成html文件存儲(chǔ)示例講解
這篇文章主要介紹了python將xml、xsl文件轉(zhuǎn)成html文件存儲(chǔ)方法,大家參考使用吧2013-12-12python讓圖片按照exif信息里的創(chuàng)建時(shí)間進(jìn)行排序的方法
這篇文章主要介紹了python讓圖片按照exif信息里的創(chuàng)建時(shí)間進(jìn)行排序的方法,涉及Python操作圖片exif獲取信息的技巧,需要的朋友可以參考下2015-03-03Python實(shí)現(xiàn)計(jì)算文件MD5和SHA1的方法示例
這篇文章主要介紹了Python實(shí)現(xiàn)計(jì)算文件MD5和SHA1的方法,結(jié)合具體實(shí)例形式分析了Python針對(duì)文件MD5及SHA1的計(jì)算方法,需要的朋友可以參考下2019-06-06python如何基于redis實(shí)現(xiàn)ip代理池
這篇文章主要介紹了python如何基于redis實(shí)現(xiàn)ip代理池,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-01-01