python爬取拉钩网职位信息写入mongodb数据库

(1)、环境准备

requests + pymongo 库

(2)、页面分析

首先登录拉钩并输入关键字:爬虫工程师

python爬取拉钩网职位信息写入mongodb数据库

我们可以发现这些数据都是js加载的

接着打开chrome的开发者工具选项并勾选XHR

python爬取拉钩网职位信息写入mongodb数据库

我们发现我们需要的信息包含在result中

python爬取拉钩网职位信息写入mongodb数据库

我们通过观察发现该请求为post请求

python爬取拉钩网职位信息写入mongodb数据库

最后我们需要模拟该请求获取数据

(3)、代码实现

python爬取拉钩网职位信息写入mongodb数据库

(4)、效果展示

python爬取拉钩网职位信息写入mongodb数据库

python爬取拉钩网职位信息写入mongodb数据库