Python 利用正则解析 json 数据
一. 案例描述
要求:解析腾讯职位的json数据,提取职位 RecruitPostName, 和 岗位网址 PostURL 。
二 . 代码实现
键值对类型,"key":"value" 类型
import re
import requests
url = "https://careers.tencent.com/tencentcareer/api/post/Query?timestamp=1616986669511&countryId=&cityId=&bgIds=&productId=&categoryId=&parentCategoryId=&attrId=&keyword=&pageIndex=1&pageSize=10&language=zh-cn&area=cn"
response = requests.get(url).text
# print(response)
RecruitPostName = re.findall('\"RecruitPostName\":\".*?\"', response)
PostURL = re.findall('\"PostURL\":\".*?\"', response)
print(RecruitPostName)
print(PostURL)
三 . 输出结果



1311

被折叠的 条评论
为什么被折叠?



