jsonpath 腾讯招聘数据读取
时间: 2023-12-24 08:03:31 浏览: 29
以下是使用jsonpath读取腾讯招聘数据的示例代码:
```python
import requests
import json
from jsonpath import jsonpath
# 发送请求
url = 'https://careers.tencent.com/tencentcareer/api/post/Query?timestamp=1626955200000&countryId=&cityId=&bgIds=&productId=&categoryId=&parentCategoryId=&attrId=&keyword=&pageIndex=1&pageSize=10&language=zh-cn&area=cn'
response = requests.get(url)
# 将响应内容转换为json格式
obj = json.loads(response.text)
# 使用jsonpath获取数据
titles = jsonpath(obj, '$..RecruitPostName')
locations = jsonpath(obj, '$..LocationName')
categories = jsonpath(obj, '$..CategoryName')
# 打印结果
for i in range(len(titles)):
print('职位名称:', titles[i])
print('工作地点:', locations[i])
print('职位类别:', categories[i])
print('------------------------')
```