哈岁NB 发表于 2023-2-6 11:23:06

爬虫json字符串提取数据

请问一下,这个json字符串的cityId怎样可以提取出来呢?

isdkz 发表于 2023-2-6 11:41:34

import requests
url = 'https://xiaoyuan.zhaopin.com/api/sou?S_SOU_FULL_INDEX=&S_SOU_POSITION_SOURCE_TYPE=&pageIndex=1&S_SOU_POSITION_TYPE=2&S_SOU_WORK_CITY=&S_SOU_JD_INDUSTRY_LEVEL=&S_SOU_COMPANY_TYPE=&S_SOU_REFRESH_DATE=&order=12&pageSize=30&_v=0.54717917&at=3325d6e3477b4d07a2edd82c1b155872&rt=6c409a2cfedf4a4e86f785b972392025&x-zp-page-request-id=4aa01edb543c49cba3d8732efd751c1a-1675654252849-231411&x-zp-client-id=86054676-5d68-46d1-9e88-f50aacd28f8d'
resp = requests.get(url)
data = resp.json()
lst = data['data']['data']['list']
for i in lst:
    print(f"城市:{i['cityDistrict'] if i['cityDistrict'] else 'null'}, 城市id: {i['cityId']}")

哈岁NB 发表于 2023-2-6 11:48:57

isdkz 发表于 2023-2-6 11:41


感谢感谢
页: [1]
查看完整版本: 爬虫json字符串提取数据