爬虫:jsonpath模块及腾讯招聘数据获取

目录

jsonpath模块

腾讯招聘数据获取


jsonpath模块

复制代码
# pip install jsonpath -i https://pypi.tuna.tsinghua.edu.cn/simple
import jsonpath

data = {
    "store": {
        "book":
            [{
            "category": "reference",
            "author": "Nigel Rees",
            "title": "Sayings of the Century",
            "price": 8.95
            },{
            "category": "fiction",
            "author": "Evelyn Waugh",
            "title": "Sword of Honour",
            "price": 12.99
            },{
            "category": "fiction",
            "author": "Herman Melville",
            "title": "Moby     Dick",
            "isbn": "0-553-21311-3",
            "price": 8.99
            }, {
            "category": "fiction",
            "author": "J. R. R. Tolkien",
            "title": "The Lord of the Rings",
            "isbn": "0-395-19395-8",
            "price": 22.99
            }],
            "bicycle":
                {"color": "red",
                "price": 19.95}
    }
}
# print(data['store']['book'][0]['title'])
# print(jsonpath.jsonpath(data,'$.store.book[*].title'))
# print(jsonpath.jsonpath(data,'$..title'))

# 在jsonpath下标中,正数下标可以直接用,负数下标要通过切片来使用
# print(jsonpath.jsonpath(data,'$.store.book[-1].title')) # False
# print(jsonpath.jsonpath(data,'$.store.book[-1:].title'))
# print(jsonpath.jsonpath(data,'$.store.book[-2:-1].title')) #获取倒数第二个
# (@.length):获取当前元素的长度
# print(jsonpath.jsonpath(data,'$.store.book[(@.length-1)].title'))

# print(jsonpath.jsonpath(data,'$..book[?(@.isbn)]'))
print(jsonpath.jsonpath(data,'$..book[?(@.price>10)]'))

腾讯招聘数据获取

复制代码
from requests_html import HTMLSession
import jsonpath

session = HTMLSession()

url = 'https://careers.tencent.com/tencentcareer/api/post/Query?timestamp=1722413528913&countryId=&cityId=&bgIds=&productId=&categoryId=&parentCategoryId=&attrId=&keyword=&pageIndex=1&pageSize=10&language=zh-cn&area=cn'

reponse = session.get(url).json()
print(jsonpath.jsonpath(reponse, '$..RecruitPostName'))
相关推荐
Y学院2 小时前
Python 数据分析:从新手到高手的“摸鱼”指南
python·数据分析
深耕AI3 小时前
【PyTorch训练】准确率计算(代码片段拆解)
人工智能·pytorch·python
eqwaak03 小时前
科技信息差(9.12)
开发语言·python·科技·量子计算
Blossom.1183 小时前
从“能写”到“能干活”:大模型工具调用(Function-Calling)的工程化落地指南
数据库·人工智能·python·深度学习·机器学习·计算机视觉·oracle
蒋星熠3 小时前
破壁者指南:内网穿透技术的深度解构与实战方法
网络·数据库·redis·python·websocket·网络协议·udp
shizidushu4 小时前
使用 Pyinstaller 打包 PPOCRLabel
python·pyinstaller
Q_Q19632884754 小时前
python+springboot+uniapp微信小程序题库系统 在线答题 题目分类 错题本管理 学习记录查询系统
spring boot·python·django·uni-app·node.js·php
Rhys..4 小时前
.gitignore文件的作用及用法
python·github
IT学长编程5 小时前
计算机毕业设计 基于深度学习的酒店评论文本情感分析研究 Python毕业设计项目 Hadoop毕业设计选题 机器学习选题【附源码+文档报告+安装调试】
hadoop·python·深度学习·机器学习·数据分析·毕业设计·酒店评论文本情感分析