{
"id": "2016021715272727370",
"text": "2016017号",
"state": "open",
"attributes": {
"url": "scxx_presale_show.php?projid=15796&id=2016021715272727370"
},
"children": [
{
"id": "0150050078004",
"text": "3号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078004"
},
"children": [
{
"id": "0150050078004",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078004"
}
},
{
"id": "0150050078004",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078004"
}
},
{
"id": "0150050078004",
"text": "02单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=02&id=0150050078004"
}
}
]
}
]
},
{
"id": "2016022309583828846",
"text": "2016023号",
"state": "open",
"attributes": {
"url": "scxx_presale_show.php?projid=15796&id=2016022309583828846"
},
"children": [
{
"id": "0150050078004",
"text": "3号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078004"
},
"children": [
{
"id": "0150050078004",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078004"
}
},
{
"id": "0150050078004",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078004"
}
},
{
"id": "0150050078004",
"text": "02单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=02&id=0150050078004"
}
}
]
},
{
"id": "0150050078005",
"text": "5号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078005"
},
"children": [
{
"id": "0150050078005",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078005"
}
},
{
"id": "0150050078005",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078005"
}
},
{
"id": "0150050078005",
"text": "02单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=02&id=0150050078005"
}
}
]
},
{
"id": "0150050078006",
"text": "6号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078006"
},
"children": [
{
"id": "0150050078006",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078006"
}
},
{
"id": "0150050078006",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078006"
}
},
{
"id": "0150050078006",
"text": "02单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=02&id=0150050078006"
}
}
]
},
{
"id": "0150050078008",
"text": "7号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078008"
},
"children": [
{
"id": "0150050078008",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078008"
}
},
{
"id": "0150050078008",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078008"
}
},
{
"id": "0150050078008",
"text": "02单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=02&id=0150050078008"
}
}
]
},
{
"id": "0150050078009",
"text": "8号住宅楼",
"state": "open",
"attributes": {
"url": "scxx_floor_show.php?projid=15796&id=0150050078009"
},
"children": [
{
"id": "0150050078009",
"text": "地下室或商铺",
"attributes": {
"url": "scxx_subroom_show.php?sub=00&id=0150050078009"
}
},
{
"id": "0150050078009",
"text": "01单元",
"attributes": {
"url": "scxx_subroom_show.php?sub=01&id=0150050078009"
}
}
]
}
]
}
}
这样直接粘贴出大段代码的问题既不利于想帮你解决问题的人查看,而且给出的代码格式上还有些问题;因此提问还是得先学会梳理问题本身,找到问题核心后再拟一个简单的模型示例后提出。
回到你的问题:整体是个
json
,可以先将 json 转换为 Python 的str
,再用正则提取所有url
,假设你的 json 数据来自网络,可以参考如下:测试了一下你的数据: