import re
a = requests.get(url, headers=headers).content.decode()
# a = """{char:{A:1,B:1,C:1,D:1,E:0,F:1,G:1,H:1,I:0,J:1,K:1,L:1,M:1,N:1,O:1,P:1,Q:1,R:1,S:1,T:1,U:0,V:0,W:1,X:1,Y:1,Z:1},brand:{A:[{type:"mb",id:9,name:"奥迪",url:"/tree_chexing/mb_9/",cur:0,num:37},{type:"mb",id:92,name:"阿尔法·罗密欧",url:"/tree_chexing/mb_92/",cur:0,num:5},{type:"mb",id:97,name:"阿斯顿·马丁",url:"/tree_chexing/mb_97/",cur:0,num:12},{type:"mb",id:268,name:"ALPINA",url:"/tree_chexing/mb_268/",cur:0,num:1},{type:"mb",id:289,name:"ARCFOX",url:"/tree_chexing/mb_289/",cur:0,num:1}],B:[{type:"mb",id:157,name:"宝骏",url:"/tree_chexing/mb_157/",cur:0,num:12},{type:"mb",id:3,name:"宝马",url:"/tree_chexing/mb_3/",cur:0,num:40},{type:"mb",id:2,name:"奔驰",url:"/tree_chexing/mb_2/",cur:0,num:55},{type:"mb",id:26,name:"本田",url:"/tree_chexing/mb_26/",cur:0,num:28},{type:"mb",id:5,name:"标致",url:"/tree_chexing/mb_5/",cur:0,num:23},{type:"mb",id:127,name:"别克",url:"/tree_chexing/mb_127/",cur:0,num:16},{type:"mb",id:15,name:"比亚迪",url:"/tree_chexing/mb_15/",cur:0,num:26},{type:"mb",id:82,name:"保时捷",url:"/tree_chexing/mb_82/",cur:0,num:10},{type:"mb",id:236,name:"宝沃",url:"/tree_chexing/mb_236/",cur:0,num:4},{type:"mb",id:59,name:"奔腾",url:"/tree_chexing/mb_59/",cur:0,num:9},{type:"mb",id:263,name:"比速",url:"/tree_chexing/mb_263/",cur:0,num:3},{type:"mb",id:195,name:"北汽绅宝",url:"/tree_chexing/mb_195/",cur:0,num:10},{type:"mb",id:211,name:"北汽幻速",url:"/tree_chexing/mb_211/",cur:0,num:9},{type:"mb",id:168,name:"北汽威旺",url:"/tree_chexing/mb_168/",cur:0,num:9},{type:"mb",id:129,name:"北汽昌河",url:"/tree_chexing/mb_129/",cur:0,num:10},{type:"mb",id:14,name:"北汽制造",url:"/tree_chexing/mb_14/",cur:0,num:13},{type:"mb",id:282,name:"北汽道达",url:"/tree_chexing/mb_282/",cur:0,num:1},{type:"mb",id:216,name:"北汽新能源",url:"/tree_chexing/mb_216/",cur:0,num:8},{type:"mb",id:163,name:"北京",url:"/tree_chexing/mb_163/",cur:0,num:4},{type:"mb",id:85,name:"宾利",url:"/tree_chexing/mb_85/",cur:0,num:6},{type:"mb",id:135,name:"布加迪",url:"/tree_chexing/mb_135/",cur:0,num:1},{type:"mb",id:172,name:"巴博斯",url:"/tree_chexing/mb_172/",cur:0,num:6}],C:[{type:"mb",id:136,name:"长安",url:"/tree_chexing/mb_136/",cur:0,num:25},{type:"mb",id:159,name:"长安欧尚",url:"/tree_chexing/mb_159/",cur:0,num:15},{type:"mb",id:281,name:"长安轻型车",url:"/tree_chexing/mb_281/",cur:0,num:9},{type:"mb",id:283,name:"长安跨越",url:"/tree_chexing/mb_283/",cur:0,num:6},{type:"mb",id:21,name:"长城",url:"/tree_chexing/mb_21/",cur:0,num:17}],D:[{type:"mb",id:8,name:"大众",url:"/tree_chexing/mb_8/",cur:0,num:41},{type:"mb",id:197,name:"东风风度",url:"/tree_chexing/mb_197/",cur:0,num:3},{type:"mb",id:253,name:"东风风光",url:"/tree_chexing/mb_253/",cur:0,num:6},{type:"mb",id:141,name:"东风风神",url:"/tree_chexing/mb_141/",cur:0,num:12},{type:"mb",id:115,name:"东风风行",url:"/tree_chexing/mb_115/",cur:0,num:14},{type:"mb",id:205,name:"东风小康",url:"/tree_chexing/mb_205/",cur:0,num:18},{type:"mb",id:27,name:"东风",url:"/tree_chexing/mb_27/",cur:0,num:14},{type:"mb",id:29,name:"东南",url:"/tree_chexing/mb_29/",cur:0,num:11},{type:"mb",id:113,name:"道奇",url:"/tree_chexing/mb_113/",cur:0,num:6},{type:"mb",id:179,name:"DS",url:"/tree_chexing/mb_179/",cur:0,num:8},{type:"mb",id:294,name:"电咖",url:"/tree_chexing/mb_294/",cur:0,num:1}],F:[{type:"mb",id:7,name:"丰田",url:"/tree_chexing/mb_7/",cur:0,num:39},{type:"mb",id:17,name:"福特",url:"/tree_chexing/mb_17/",cur:0,num:28},{type:"mb",id:40,name:"菲亚特",url:"/tree_chexing/mb_40/",cur:0,num:12},{type:"mb",id:91,name:"法拉利",url:"/tree_chexing/mb_91/",cur:0,num:16},{type:"mb",id:67,name:"福迪",url:"/tree_chexing/mb_67/",cur:0,num:9},{type:"mb",id:208,name:"福汽启腾",url:"/tree_chexing/mb_208/",cur:0,num:4},{type:"mb",id:128,name:"福田",url:"/tree_chexing/mb_128/",cur:0,num:35},{type:"mb",id:257,name:"Faraday Future",url:"/tree_chexing/mb_257/",cur:0,num:1}],G:[{type:"mb",id:147,name:"广汽传祺",url:"/tree_chexing/mb_147/",cur:0,num:14},{type:"mb",id:295,name:"广汽新能源",url:"/tree_chexing/mb_295/",cur:0,num:3},{type:"mb",id:63,name:"广汽吉奥",url:"/tree_chexing/mb_63/",cur:0,num:20},{type:"mb",id:133,name:"广汽日野",url:"/tree_chexing/mb_133/",cur:0,num:3},{type:"mb",id:182,name:"观致",url:"/tree_chexing/mb_182/",cur:0,num:3},{type:"mb",id:290,name:"国金",url:"/tree_chexing/mb_290/",cur:0,num:1},{type:"mb",id:109,name:"GMC",url:"/tree_chexing/mb_109/",cur:0,num:3},{type:"mb",id:110,name:"光冈",url:"/tree_chexing/mb_110/",cur:0,num:3}],H:[{type:"mb",id:196,name:"哈弗",url:"/tree_chexing/mb_196/",cur:0,num:12},{type:"mb",id:32,name:"海马",url:"/tree_chexing/mb_32/",cur:0,num:24},{type:"mb",id:259,name:"汉腾",url:"/tree_chexing/mb_259/",cur:0,num:3},{type:"mb",id:58,name:"红旗",url:"/tree_chexing/mb_58/",cur:0,num:5},{type:"mb",id:112,name:"华泰",url:"/tree_chexing/mb_112/",cur:0,num:13},{type:"mb",id:31,name:"哈飞",url:"/tree_chexing/mb_31/",cur:0,num:12},{type:"mb",id:108,name:"悍马",url:"/tree_chexing/mb_108/",cur:0,num:2},{type:"mb",id:181,name:"恒天",url:"/tree_chexing/mb_181/",cur:0,num:3},{type:"mb",id:262,name:"华凯",url:"/tree_chexing/mb_262/",cur:0,num:1},{type:"mb",id:52,name:"黄海",url:"/tree_chexing/mb_52/",cur:0,num:18},{type:"mb",id:44,name:"华普",url:"/tree_chexing/mb_44/",cur:0,num:5},{type:"mb",id:292,name:"华骐",url:"/tree_chexing/mb_292/",cur:0,num:1},{type:"mb",id:225,name:"华颂",url:"/tree_chexing/mb_225/",cur:0,num:1},{type:"mb",id:45,name:"汇众",url:"/tree_chexing/mb_45/",cur:0,num:2}],J:[{type:"mb",id:34,name:"吉利",url:"/tree_chexing/mb_34/",cur:0,num:33},{type:"mb",id:35,name:"江淮",url:"/tree_chexing/mb_35/",cur:0,num:30},{type:"mb",id:98,name:"捷豹",url:"/tree_chexing/mb_98/",cur:0,num:11},{type:"mb",id:4,name:"Jeep",url:"/tree_chexing/mb_4/",cur:0,num:12},{type:"mb",id:296,name:"捷途",url:"/tree_chexing/mb_296/",cur:0,num:2},{type:"mb",id:37,name:"江铃",url:"/tree_chexing/mb_37/",cur:0,num:27},{type:"mb",id:39,name:"金杯",url:"/tree_chexing/mb_39/",cur:0,num:27},{type:"mb",id:57,name:"金龙",url:"/tree_chexing/mb_57/",cur:0,num:4},{type:"mb",id:161,name:"金旅",url:"/tree_chexing/mb_161/",cur:0,num:3},{type:"mb",id:152,name:"九龙",url:"/tree_chexing/mb_152/",cur:0,num:4},{type:"mb",id:279,name:"君马",url:"/tree_chexing/mb_279/",cur:0,num:3}],K:[{type:"mb",id:107,name:"凯迪拉克",url:"/tree_chexing/mb_107/",cur:0,num:12},{type:"mb",id:220,name:"凯翼",url:"/tree_chexing/mb_220/",cur:0,num:6},{type:"mb",id:51,name:"克莱斯勒",url:"/tree_chexing/mb_51/",cur:0,num:10},{type:"mb",id:150,name:"开瑞",url:"/tree_chexing/mb_150/",cur:0,num:11},{type:"mb",id:214,name:"卡升",url:"/tree_chexing/mb_214/",cur:0,num:6},{type:"mb",id:213,name:"卡威",url:"/tree_chexing/mb_213/",cur:0,num:4},{type:"mb",id:145,name:"科尼赛克",url:"/tree_chexing/mb_145/",cur:0,num:2},{type:"mb",id:212,name:"KTM",url:"/tree_chexing/mb_212/",cur:0,num:1},{type:"mb",id:188,name:"卡尔森",url:"/tree_chexing/mb_188/",cur:0,num:3}],L:[{type:"mb",id:94,name:"雷克萨斯",url:"/tree_chexing/mb_94/",cur:0,num:15},{type:"mb",id:99,name:"雷诺",url:"/tree_chexing/mb_99/",cur:0,num:12},{type:"mb",id:267,name:"领克",url:"/tree_chexing/mb_267/",cur:0,num:3},{type:"mb",id:95,name:"林肯",url:"/tree_chexing/mb_95/",cur:0,num:9},{type:"mb",id:36,name:"陆风",url:"/tree_chexing/mb_36/",cur:0,num:10},{type:"mb",id:96,name:"路虎",url:"/tree_chexing/mb_96/",cur:0,num:12},{type:"mb",id:76,name:"力帆",url:"/tree_chexing/mb_76/",cur:0,num:19},{type:"mb",id:16,name:"铃木",url:"/tree_chexing/mb_16/",cur:0,num:20},{type:"mb",id:80,name:"劳斯莱斯",url:"/tree_chexing/mb_80/",cur:0,num:5},{type:"mb",id:86,name:"兰博基尼",url:"/tree_chexing/mb_86/",cur:0,num:5},{type:"mb",id:146,name:"莲花",url:"/tree_chexing/mb_146/",cur:0,num:3},{type:"mb",id:153,name:"猎豹",url:"/tree_chexing/mb_153/",cur:0,num:20},{type:"mb",id:166,name:"理念",url:"/tree_chexing/mb_166/",cur:0,num:1},{type:"mb",id:83,name:"路特斯",url:"/tree_chexing/mb_83/",cur:0,num:3}],M:[{type:"mb",id:18,name:"马自达",url:"/tree_chexing/mb_18/",cur:0,num:20},{type:"mb",id:79,name:"名爵",url:"/tree_chexing/mb_79/",cur:0,num:10},{type:"mb",id:81,name:"MINI",url:"/tree_chexing/mb_81/",cur:0,num:12},{type:"mb",id:88,name:"迈巴赫",url:"/tree_chexing/mb_88/",cur:0,num:4},{type:"mb",id:183,name:"迈凯伦",url:"/tree_chexing/mb_183/",cur:0,num:9},{type:"mb",id:93,name:"玛莎拉蒂",url:"/tree_chexing/mb_93/",cur:0,num:8},{type:"mb",id:201,name:"摩根",url:"/tree_chexing/mb_201/",cur:0,num:7}],N:[{type:"mb",id:155,name:"纳智捷",url:"/tree_chexing/mb_155/",cur:0,num:7}],O:[{type:"mb",id:84,name:"讴歌",url:"/tree_chexing/mb_84/",cur:0,num:11},{type:"mb",id:104,name:"欧宝",url:"/tree_chexing/mb_104/",cur:0,num:7},{type:"mb",id:171,name:"欧朗",url:"/tree_chexing/mb_171/",cur:0,num:1}],P:[{type:"mb",id:185,name:"帕加尼",url:"/tree_chexing/mb_185/",cur:0,num:1},{type:"mb",id:293,name:"Polestar",url:"/tree_chexing/mb_293/",cur:0,num:1}],Q:[{type:"mb",id:42,name:"奇瑞",url:"/tree_chexing/mb_42/",cur:0,num:37},{type:"mb",id:156,name:"启辰",url:"/tree_chexing/mb_156/",cur:0,num:10},{type:"mb",id:28,name:"起亚",url:"/tree_chexing/mb_28/",cur:0,num:33},{type:"mb",id:231,name:"前途",url:"/tree_chexing/mb_231/",cur:0,num:1},{type:"mb",id:287,name:"奇点汽车",url:"/tree_chexing/mb_287/",cur:0,num:1},{type:"mb",id:43,name:"庆铃",url:"/tree_chexing/mb_43/",cur:0,num:1}],R:[{type:"mb",id:30,name:"日产",url:"/tree_chexing/mb_30/",cur:0,num:33},{type:"mb",id:78,name:"荣威",url:"/tree_chexing/mb_78/",cur:0,num:18},{type:"mb",id:142,name:"瑞麒",url:"/tree_chexing/mb_142/",cur:0,num:5}],S:[{type:"mb",id:10,name:"斯柯达",url:"/tree_chexing/mb_10/",cur:0,num:16},{type:"mb",id:111,name:"斯巴鲁",url:"/tree_chexing/mb_111/",cur:0,num:8},{type:"mb",id:89,name:"smart",url:"/tree_chexing/mb_89/",cur:0,num:3},{type:"mb",id:260,name:"SWM斯威",url:"/tree_chexing/mb_260/",cur:0,num:3},{type:"mb",id:103,name:"萨博",url:"/tree_chexing/mb_103/",cur:0,num:2},{type:"mb",id:239,name:"赛麟",url:"/tree_chexing/mb_239/",cur:0,num:3},{type:"mb",id:25,name:"三菱",url:"/tree_chexing/mb_25/",cur:0,num:20},{type:"mb",id:165,name:"上汽大通",url:"/tree_chexing/mb_165/",cur:0,num:7},{type:"mb",id:209,name:"山姆",url:"/tree_chexing/mb_209/",cur:0,num:6},{type:"mb",id:137,name:"世爵",url:"/tree_chexing/mb_137/",cur:0,num:1},{type:"mb",id:50,name:"双环",url:"/tree_chexing/mb_50/",cur:0,num:3},{type:"mb",id:102,name:"双龙",url:"/tree_chexing/mb_102/",cur:0,num:9}],T:[{type:"mb",id:189,name:"特斯拉",url:"/tree_chexing/mb_189/",cur:0,num:3},{type:"mb",id:175,name:"腾势",url:"/tree_chexing/mb_175/",cur:0,num:1}],W:[{type:"mb",id:48,name:"五菱",url:"/tree_chexing/mb_48/",cur:0,num:14},{type:"mb",id:19,name:"沃尔沃",url:"/tree_chexing/mb_19/",cur:0,num:22},{type:"mb",id:270,name:"WEY",url:"/tree_chexing/mb_270/",cur:0,num:4},{type:"mb",id:266,name:"蔚来",url:"/tree_chexing/mb_266/",cur:0,num:2},{type:"mb",id:132,name:"五十铃",url:"/tree_chexing/mb_132/",cur:0,num:4},{type:"mb",id:247,name:"潍柴欧睿",url:"/tree_chexing/mb_247/",cur:0,num:1},{type:"mb",id:207,name:"潍柴英致",url:"/tree_chexing/mb_207/",cur:0,num:4},{type:"mb",id:140,name:"威麟",url:"/tree_chexing/mb_140/",cur:0,num:4},{type:"mb",id:298,name:"威马汽车",url:"/tree_chexing/mb_298/",cur:0,num:1},{type:"mb",id:186,name:"威兹曼",url:"/tree_chexing/mb_186/",cur:0,num:2}],X:[{type:"mb",id:49,name:"雪佛兰",url:"/tree_chexing/mb_49/",cur:0,num:22},{type:"mb",id:6,name:"雪铁龙",url:"/tree_chexing/mb_6/",cur:0,num:19},{type:"mb",id:13,name:"现代",url:"/tree_chexing/mb_13/",cur:0,num:36},{type:"mb",id:297,name:"小鹏汽车",url:"/tree_chexing/mb_297/",cur:0,num:1},{type:"mb",id:286,name:"星驰",url:"/tree_chexing/mb_286/",cur:0,num:3},{type:"mb",id:87,name:"西雅特",url:"/tree_chexing/mb_87/",cur:0,num:3}],Y:[{type:"mb",id:100,name:"英菲尼迪",url:"/tree_chexing/mb_100/",cur:0,num:18},{type:"mb",id:258,name:"驭胜",url:"/tree_chexing/mb_258/",cur:0,num:2},{type:"mb",id:138,name:"野马",url:"/tree_chexing/mb_138/",cur:0,num:10},{type:"mb",id:53,name:"一汽",url:"/tree_chexing/mb_53/",cur:0,num:29},{type:"mb",id:41,name:"依维柯",url:"/tree_chexing/mb_41/",cur:0,num:8},{type:"mb",id:75,name:"永源",url:"/tree_chexing/mb_75/",cur:0,num:5},{type:"mb",id:291,name:"裕路",url:"/tree_chexing/mb_291/",cur:0,num:1},{type:"mb",id:285,name:"云度",url:"/tree_chexing/mb_285/",cur:0,num:3}],Z:[{type:"mb",id:77,name:"众泰",url:"/tree_chexing/mb_77/",cur:0,num:29},{type:"mb",id:60,name:"中华",url:"/tree_chexing/mb_60/",cur:0,num:18},{type:"mb",id:233,name:"知豆",url:"/tree_chexing/mb_233/",cur:0,num:4},{type:"mb",id:203,name:"之诺",url:"/tree_chexing/mb_203/",cur:0,num:1},{type:"mb",id:33,name:"中兴",url:"/tree_chexing/mb_33/",cur:0,num:10}]}}
# """
# print(a)
用正则匹配一段类似于字典格式的字符串
aa = re.findall('.*(brand.*}]})}', a)[0]
# print(aa)
进行加减"号处理
b = aa.replace('"', '').replace('{', '{"').replace('}', '"}').replace(':', '":"').replace(',', '","').replace \
('"{', '{').replace('}"', '}').replace('"[', '[').replace(']"', ']').replace(':', ':').replace('brand":', '')
print(b)
print(json.loads(b))
网友评论