如何使用正则表达式获取JSON值

2024-10-01 17:30:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正试图学习从一个网站获取JSON值,该网站中有一个脚本,其中包含JSON,我正试图使用正则表达式获取该脚本

现在我已经尝试过:jsonConfig":\s*.*}它确实找到了一个匹配项,但没有对它进行分组(这意味着我无法获得稍后用json.loads解析它的值,我将在这个线程的最底部显示这个值)

"Magento_Swatches/js/swatch-renderer": {
                "jsonConfig": {"attributes":{"203":{"id":"203","code":"sizefootwear_conf","label":"EU","options":[{"id":"6320","label":"38","products":["69813"]},{"id":"6351","label":"38,5","products":["69817"]},{"id":"6335","label":"39","products":["69818"]},{"id":"6354","label":"40","products":["69819"]},{"id":"6338","label":"40,5","products":["69820"]},{"id":"6357","label":"41","products":["69821"]},{"id":"6326","label":"42","products":["69822"]},{"id":"6362","label":"42,5","products":["69823"]},{"id":"6341","label":"43","products":["69824"]},{"id":"6365","label":"44","products":["69814"]},{"id":"6344","label":"44,5","products":["69815"]},{"id":"6370","label":"45,5","products":["69816"]}],"position":"0"},"205":{"id":"205","code":"sizefootwearus_conf","label":"US","options":[{"id":"6319","label":"5,5","products":["69813"]},{"id":"6372","label":"6,0","products":["69817"]},{"id":"6334","label":"6,5","products":["69818"]},{"id":"6350","label":"7,0","products":["69819"]},{"id":"6337","label":"7,5","products":["69820"]},{"id":"6353","label":"8,0","products":["69821"]},{"id":"6325","label":"8,5","products":["69822"]},{"id":"6356","label":"9,0","products":["69823"]},{"id":"6340","label":"9,5","products":["69824"]},{"id":"6364","label":"10,0","products":["69814"]},{"id":"6343","label":"10,5","products":["69815"]},{"id":"6328","label":"11,5","products":["69816"]}],"position":"1"},"204":{"id":"204","code":"sizefootwearuk_conf","label":"UK","options":[{"id":"6318","label":"5,0","products":["69813"]},{"id":"6352","label":"5,5","products":["69817"]},{"id":"6743","label":"6,0-EU39","products":["69818"]},{"id":"6744","label":"6,0-EU40","products":["69819"]},{"id":"6355","label":"6,5","products":["69820"]},{"id":"6336","label":"7,0","products":["69821"]},{"id":"6361","label":"7,5","products":["69822"]},{"id":"6324","label":"8,0","products":["69823"]},{"id":"6363","label":"8,5","products":["69824"]},{"id":"6339","label":"9,0","products":["69814"]},{"id":"6366","label":"9,5","products":["69815"]},{"id":"6369","label":"10,5","products":["69816"]}],"position":"2"}},"template":"\u20ac<%- data.price %>","currencyFormat":"\u20ac%s","optionPrices":{"69813":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69814":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69815":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69816":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69817":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69818":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69819":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69820":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69821":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69822":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69823":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69824":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}}},"priceFormat":{"pattern":"\u20ac%s","precision":2,"requiredPrecision":2,"decimalSymbol":".","groupSymbol":",","groupLength":3,"integerRequired":false},"prices":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99}},"productId":"69825","chooseText":"Choose an Option...","images":[],"index":{"69813":{"203":"6320","205":"6319","204":"6318"},"69814":{"203":"6365","205":"6364","204":"6339"},"69815":{"203":"6344","205":"6343","204":"6366"},"69816":{"203":"6370","205":"6328","204":"6369"},"69817":{"203":"6351","205":"6372","204":"6352"},"69818":{"203":"6335","205":"6334","204":"6743"},"69819":{"203":"6354","205":"6350","204":"6744"},"69820":{"203":"6338","205":"6337","204":"6355"},"69821":{"203":"6357","205":"6353","204":"6336"},"69822":{"203":"6326","205":"6325","204":"6361"},"69823":{"203":"6362","205":"6356","204":"6324"},"69824":{"203":"6341","205":"6340","204":"6363"}},"productStockAlert":{"entity":"69825","map":{"203":{"label":"52,5","":"","6610":"6610","6498":"6498","6582":"6582","6516":"6516","6501":"6501","6518":"6518","6504":"6504","6395":"6395","6404":"6404","6533":"6533","6407":"6407","6530":"6530","6410":"6410","6413":"6413","6416":"6416","6534":"6534","6419":"6419","6422":"6422","6425":"6425","6398":"6398","6401":"6401","6531":"6531","6431":"6431","6443":"6443","6446":"6446","6495":"6495","6449":"6449","6452":"6452","6455":"6455","6458":"6458","6461":"6461","6807":"6807","6464":"6464","6434":"6434","6437":"6437","6558":"6558","6440":"6440","6480":"6480","6481":"6481","6382":"6382","6465":"6465","6631":"6631","6332":"6332","6466":"6466","6348":"6348","6634":"6634","6320":"6320","6351":"6351","6384":"6384","6659":"6659","6335":"6335","6388":"6388","6508":"6508","6354":"6354","6338":"6338","6389":"6389","6664":"6664","6357":"6357","6390":"6390","6506":"6506","6637":"6637","6326":"6326","6362":"6362","6391":"6391","6640":"6640","6341":"6341","6392":"6392","6560":"6560","6365":"6365","6344":"6344","6385":"6385","6838":"6838","6368":"6368","6386":"6386","6370":"6370","6643":"6643","6628":"6628","6329":"6329","6529":"6529","6387":"6387","6843":"6843","6347":"6347","6470":"6470","6360":"6360","6646":"6646","6472":"6472","6323":"6323","6564":"6564","6593":"6593","6474":"6474","6376":"6376","6565":"6565","6561":"6561","6567":"6567","6604":"6604","6607":"6607"},"205":{"label":"18,0","":"","6513":"6513","6497":"6497","6583":"6583","6500":"6500","6821":"6821","6503":"6503","6532":"6532","6394":"6394","6403":"6403","6406":"6406","6409":"6409","6412":"6412","6415":"6415","6418":"6418","6421":"6421","6424":"6424","6397":"6397","6400":"6400","6430":"6430","6442":"6442","6445":"6445","6448":"6448","6451":"6451","6454":"6454","6457":"6457","6460":"6460","6463":"6463","6433":"6433","6436":"6436","6439":"6439","6555":"6555","6468":"6468","6507":"6507","6632":"6632","6331":"6331","6319":"6319","6635":"6635","6372":"6372","6334":"6334","6661":"6661","6350":"6350","6337":"6337","6663":"6663","6353":"6353","6619":"6619","6325":"6325","6621":"6621","6638":"6638","6356":"6356","6340":"6340","6623":"6623","6641":"6641","6364":"6364","6343":"6343","6625":"6625","6840":"6840","6367":"6367","6328":"6328","6644":"6644","6371":"6371","6346":"6346","6842":"6842","6359":"6359","6322":"6322","6647":"6647","6373":"6373","6566":"6566","6375":"6375","6562":"6562","6605":"6605","6608":"6608"},"204":{"label":"17,0","":"","6611":"6611","6514":"6514","6496":"6496","6515":"6515","6499":"6499","6517":"6517","6502":"6502","6393":"6393","6505":"6505","6402":"6402","6405":"6405","6408":"6408","6411":"6411","6414":"6414","6417":"6417","6420":"6420","6423":"6423","6396":"6396","6399":"6399","6429":"6429","6745":"6745","6441":"6441","6444":"6444","6447":"6447","6450":"6450","6453":"6453","6456":"6456","6459":"6459","6462":"6462","6432":"6432","6435":"6435","6438":"6438","6467":"6467","6381":"6381","6633":"6633","6330":"6330","6349":"6349","6636":"6636","6318":"6318","6352":"6352","6660":"6660","6333":"6333","6743":"6743","6744":"6744","6355":"6355","6662":"6662","6336":"6336","6620":"6620","6361":"6361","6622":"6622","6639":"6639","6324":"6324","6363":"6363","6624":"6624","6642":"6642","6339":"6339","6366":"6366","6626":"6626","6839":"6839","6342":"6342","6627":"6627","6369":"6369","6645":"6645","6327":"6327","6358":"6358","6841":"6841","6345":"6345","6471":"6471","6648":"6648","6321":"6321","6473":"6473","6374":"6374","6563":"6563","6606":"6606","6609":"6609"}},"child":{"6320_6319_6318_":{"entity":"69813","stock_number":0,"stock_status":false,"productId":"69813","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6365_6364_6339_":{"entity":"69814","stock_number":5,"stock_status":true,"productId":"69814","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6344_6343_6366_":{"entity":"69815","stock_number":3,"stock_status":true,"productId":"69815","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6370_6328_6369_":{"entity":"69816","stock_number":1,"stock_status":true,"productId":"69816","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6351_6372_6352_":{"entity":"69817","stock_number":0,"stock_status":false,"productId":"69817","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6335_6334_6743_":{"entity":"69818","stock_number":0,"stock_status":false,"productId":"69818","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6354_6350_6744_":{"entity":"69819","stock_number":0,"stock_status":false,"productId":"69819","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6338_6337_6355_":{"entity":"69820","stock_number":0,"stock_status":false,"productId":"69820","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6357_6353_6336_":{"entity":"69821","stock_number":3,"stock_status":true,"productId":"69821","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6326_6325_6361_":{"entity":"69822","stock_number":4,"stock_status":true,"productId":"69822","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6362_6356_6324_":{"entity":"69823","stock_number":6,"stock_status":true,"productId":"69823","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6341_6340_6363_":{"entity":"69824","stock_number":6,"stock_status":true,"productId":"69824","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"}}},"stock":{"69813":0,"69814":5,"69815":3,"69816":1,"69817":0,"69818":0,"69819":0,"69820":0,"69821":3,"69822":4,"69823":6,"69824":6}},
                "jsonSwatchConfig": {"203":{"6320":{"type":"0","value":"38","label":"38"},"6351":{"type":"0","value":"38,5","label":"38,5"},"6335":{"type":"0","value":"39","label":"39"},"6354":{"type":"0","value":"40","label":"40"},"6338":{"type":"0","value":"40,5","label":"40,5"},"6357":{"type":"0","value":"41","label":"41"},"6326":{"type":"0","value":"42","label":"42"},"6362":{"type":"0","value":"42,5","label":"42,5"},"6341":{"type":"0","value":"43","label":"43"},"6365":{"type":"0","value":"44","label":"44"},"6344":{"type":"0","value":"44,5","label":"44,5"},"6370":{"type":"0","value":"45,5","label":"45,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"},"205":{"6319":{"type":"0","value":"5,5","label":"5,5"},"6372":{"type":"0","value":"6,0","label":"6,0"},"6334":{"type":"0","value":"6,5","label":"6,5"},"6350":{"type":"0","value":"7,0","label":"7,0"},"6337":{"type":"0","value":"7,5","label":"7,5"},"6353":{"type":"0","value":"8,0","label":"8,0"},"6325":{"type":"0","value":"8,5","label":"8,5"},"6356":{"type":"0","value":"9,0","label":"9,0"},"6340":{"type":"0","value":"9,5","label":"9,5"},"6364":{"type":"0","value":"10,0","label":"10,0"},"6343":{"type":"0","value":"10,5","label":"10,5"},"6328":{"type":"0","value":"11,5","label":"11,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"},"204":{"6318":{"type":"0","value":"5,0","label":"5,0"},"6352":{"type":"0","value":"5,5","label":"5,5"},"6743":{"type":"0","value":"6,0-EU39","label":"6,0-EU39"},"6744":{"type":"0","value":"6,0-EU40","label":"6,0-EU40"},"6355":{"type":"0","value":"6,5","label":"6,5"},"6336":{"type":"0","value":"7,0","label":"7,0"},"6361":{"type":"0","value":"7,5","label":"7,5"},"6324":{"type":"0","value":"8,0","label":"8,0"},"6363":{"type":"0","value":"8,5","label":"8,5"},"6339":{"type":"0","value":"9,0","label":"9,0"},"6366":{"type":"0","value":"9,5","label":"9,5"},"6369":{"type":"0","value":"10,5","label":"10,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"}},
                "mediaCallback": "https\u003A\u002F\u002Fwww.bstn.com\u002Feu_en\u002Fswatches\u002Fajax\u002Fmedia\u002F",
                "gallerySwitchStrategy": "prepend",
                "jsonSwatchImageSizeConfig": {"swatchImage":{"width":30,"height":20},"swatchThumb":{"height":90,"width":110}},
                "showTooltip": 1    

我正在尝试获取"jsonConfig":值,我想知道如何使用我稍后将使用的正则表达式:

getJsonConfig= json.loads(
                    '{}'.format(
                        re.search(
                            r'`jsonConfig":\s*.*}',
                        response.text,
                        re.M | re.S
                    ).group(1)
                )
            )

Tags: httpsidvaluetypestockamountlabelproducts
1条回答
网友
1楼 · 发布于 2024-10-01 17:30:33

用括号捕捉内容:

r'"jsonConfig":\s*(.*})'

regex proof

解释

                                        
  "jsonConfig":            '"jsonConfig":'
                                        
  \s*                      whitespace (\n, \r, \t, \f, and " ") (0 or
                           more times (matching the most amount
                           possible))
                                        
  (                        group and capture to \1:
                                        
    .*                       any character except \n (0 or more times
                             (matching the most amount possible))
                                        
    }                        '}'
                                        
  )                        end of \1

Python proof

import re,json
string = r'''"Magento_Swatches/js/swatch-renderer": {
                "jsonConfig": {"attributes":{"203":{"id":"203","code":"sizefootwear_conf","label":"EU","options":[{"id":"6320","label":"38","products":["69813"]},{"id":"6351","label":"38,5","products":["69817"]},{"id":"6335","label":"39","products":["69818"]},{"id":"6354","label":"40","products":["69819"]},{"id":"6338","label":"40,5","products":["69820"]},{"id":"6357","label":"41","products":["69821"]},{"id":"6326","label":"42","products":["69822"]},{"id":"6362","label":"42,5","products":["69823"]},{"id":"6341","label":"43","products":["69824"]},{"id":"6365","label":"44","products":["69814"]},{"id":"6344","label":"44,5","products":["69815"]},{"id":"6370","label":"45,5","products":["69816"]}],"position":"0"},"205":{"id":"205","code":"sizefootwearus_conf","label":"US","options":[{"id":"6319","label":"5,5","products":["69813"]},{"id":"6372","label":"6,0","products":["69817"]},{"id":"6334","label":"6,5","products":["69818"]},{"id":"6350","label":"7,0","products":["69819"]},{"id":"6337","label":"7,5","products":["69820"]},{"id":"6353","label":"8,0","products":["69821"]},{"id":"6325","label":"8,5","products":["69822"]},{"id":"6356","label":"9,0","products":["69823"]},{"id":"6340","label":"9,5","products":["69824"]},{"id":"6364","label":"10,0","products":["69814"]},{"id":"6343","label":"10,5","products":["69815"]},{"id":"6328","label":"11,5","products":["69816"]}],"position":"1"},"204":{"id":"204","code":"sizefootwearuk_conf","label":"UK","options":[{"id":"6318","label":"5,0","products":["69813"]},{"id":"6352","label":"5,5","products":["69817"]},{"id":"6743","label":"6,0-EU39","products":["69818"]},{"id":"6744","label":"6,0-EU40","products":["69819"]},{"id":"6355","label":"6,5","products":["69820"]},{"id":"6336","label":"7,0","products":["69821"]},{"id":"6361","label":"7,5","products":["69822"]},{"id":"6324","label":"8,0","products":["69823"]},{"id":"6363","label":"8,5","products":["69824"]},{"id":"6339","label":"9,0","products":["69814"]},{"id":"6366","label":"9,5","products":["69815"]},{"id":"6369","label":"10,5","products":["69816"]}],"position":"2"}},"template":"\u20ac<%- data.price %>","currencyFormat":"\u20ac%s","optionPrices":{"69813":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69814":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69815":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69816":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69817":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69818":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69819":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69820":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69821":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69822":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69823":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}},"69824":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99},"tierPrices":[],"msrpPrice":{"amount":null}}},"priceFormat":{"pattern":"\u20ac%s","precision":2,"requiredPrecision":2,"decimalSymbol":".","groupSymbol":",","groupLength":3,"integerRequired":false},"prices":{"oldPrice":{"amount":139.99},"basePrice":{"amount":117.63865446218},"finalPrice":{"amount":139.99}},"productId":"69825","chooseText":"Choose an Option...","images":[],"index":{"69813":{"203":"6320","205":"6319","204":"6318"},"69814":{"203":"6365","205":"6364","204":"6339"},"69815":{"203":"6344","205":"6343","204":"6366"},"69816":{"203":"6370","205":"6328","204":"6369"},"69817":{"203":"6351","205":"6372","204":"6352"},"69818":{"203":"6335","205":"6334","204":"6743"},"69819":{"203":"6354","205":"6350","204":"6744"},"69820":{"203":"6338","205":"6337","204":"6355"},"69821":{"203":"6357","205":"6353","204":"6336"},"69822":{"203":"6326","205":"6325","204":"6361"},"69823":{"203":"6362","205":"6356","204":"6324"},"69824":{"203":"6341","205":"6340","204":"6363"}},"productStockAlert":{"entity":"69825","map":{"203":{"label":"52,5","":"","6610":"6610","6498":"6498","6582":"6582","6516":"6516","6501":"6501","6518":"6518","6504":"6504","6395":"6395","6404":"6404","6533":"6533","6407":"6407","6530":"6530","6410":"6410","6413":"6413","6416":"6416","6534":"6534","6419":"6419","6422":"6422","6425":"6425","6398":"6398","6401":"6401","6531":"6531","6431":"6431","6443":"6443","6446":"6446","6495":"6495","6449":"6449","6452":"6452","6455":"6455","6458":"6458","6461":"6461","6807":"6807","6464":"6464","6434":"6434","6437":"6437","6558":"6558","6440":"6440","6480":"6480","6481":"6481","6382":"6382","6465":"6465","6631":"6631","6332":"6332","6466":"6466","6348":"6348","6634":"6634","6320":"6320","6351":"6351","6384":"6384","6659":"6659","6335":"6335","6388":"6388","6508":"6508","6354":"6354","6338":"6338","6389":"6389","6664":"6664","6357":"6357","6390":"6390","6506":"6506","6637":"6637","6326":"6326","6362":"6362","6391":"6391","6640":"6640","6341":"6341","6392":"6392","6560":"6560","6365":"6365","6344":"6344","6385":"6385","6838":"6838","6368":"6368","6386":"6386","6370":"6370","6643":"6643","6628":"6628","6329":"6329","6529":"6529","6387":"6387","6843":"6843","6347":"6347","6470":"6470","6360":"6360","6646":"6646","6472":"6472","6323":"6323","6564":"6564","6593":"6593","6474":"6474","6376":"6376","6565":"6565","6561":"6561","6567":"6567","6604":"6604","6607":"6607"},"205":{"label":"18,0","":"","6513":"6513","6497":"6497","6583":"6583","6500":"6500","6821":"6821","6503":"6503","6532":"6532","6394":"6394","6403":"6403","6406":"6406","6409":"6409","6412":"6412","6415":"6415","6418":"6418","6421":"6421","6424":"6424","6397":"6397","6400":"6400","6430":"6430","6442":"6442","6445":"6445","6448":"6448","6451":"6451","6454":"6454","6457":"6457","6460":"6460","6463":"6463","6433":"6433","6436":"6436","6439":"6439","6555":"6555","6468":"6468","6507":"6507","6632":"6632","6331":"6331","6319":"6319","6635":"6635","6372":"6372","6334":"6334","6661":"6661","6350":"6350","6337":"6337","6663":"6663","6353":"6353","6619":"6619","6325":"6325","6621":"6621","6638":"6638","6356":"6356","6340":"6340","6623":"6623","6641":"6641","6364":"6364","6343":"6343","6625":"6625","6840":"6840","6367":"6367","6328":"6328","6644":"6644","6371":"6371","6346":"6346","6842":"6842","6359":"6359","6322":"6322","6647":"6647","6373":"6373","6566":"6566","6375":"6375","6562":"6562","6605":"6605","6608":"6608"},"204":{"label":"17,0","":"","6611":"6611","6514":"6514","6496":"6496","6515":"6515","6499":"6499","6517":"6517","6502":"6502","6393":"6393","6505":"6505","6402":"6402","6405":"6405","6408":"6408","6411":"6411","6414":"6414","6417":"6417","6420":"6420","6423":"6423","6396":"6396","6399":"6399","6429":"6429","6745":"6745","6441":"6441","6444":"6444","6447":"6447","6450":"6450","6453":"6453","6456":"6456","6459":"6459","6462":"6462","6432":"6432","6435":"6435","6438":"6438","6467":"6467","6381":"6381","6633":"6633","6330":"6330","6349":"6349","6636":"6636","6318":"6318","6352":"6352","6660":"6660","6333":"6333","6743":"6743","6744":"6744","6355":"6355","6662":"6662","6336":"6336","6620":"6620","6361":"6361","6622":"6622","6639":"6639","6324":"6324","6363":"6363","6624":"6624","6642":"6642","6339":"6339","6366":"6366","6626":"6626","6839":"6839","6342":"6342","6627":"6627","6369":"6369","6645":"6645","6327":"6327","6358":"6358","6841":"6841","6345":"6345","6471":"6471","6648":"6648","6321":"6321","6473":"6473","6374":"6374","6563":"6563","6606":"6606","6609":"6609"}},"child":{"6320_6319_6318_":{"entity":"69813","stock_number":0,"stock_status":false,"productId":"69813","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6365_6364_6339_":{"entity":"69814","stock_number":5,"stock_status":true,"productId":"69814","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6344_6343_6366_":{"entity":"69815","stock_number":3,"stock_status":true,"productId":"69815","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6370_6328_6369_":{"entity":"69816","stock_number":1,"stock_status":true,"productId":"69816","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6351_6372_6352_":{"entity":"69817","stock_number":0,"stock_status":false,"productId":"69817","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6335_6334_6743_":{"entity":"69818","stock_number":0,"stock_status":false,"productId":"69818","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6354_6350_6744_":{"entity":"69819","stock_number":0,"stock_status":false,"productId":"69819","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6338_6337_6355_":{"entity":"69820","stock_number":0,"stock_status":false,"productId":"69820","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6357_6353_6336_":{"entity":"69821","stock_number":3,"stock_status":true,"productId":"69821","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6326_6325_6361_":{"entity":"69822","stock_number":4,"stock_status":true,"productId":"69822","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6362_6356_6324_":{"entity":"69823","stock_number":6,"stock_status":true,"productId":"69823","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"},"6341_6340_6363_":{"entity":"69824","stock_number":6,"stock_status":true,"productId":"69824","parent_url":"https:\/\/www.bstn.com\/eu_en\/p\/jordan-jordan-why-not-zer0-4-dd4889-006-0250549"}}},"stock":{"69813":0,"69814":5,"69815":3,"69816":1,"69817":0,"69818":0,"69819":0,"69820":0,"69821":3,"69822":4,"69823":6,"69824":6}},
                "jsonSwatchConfig": {"203":{"6320":{"type":"0","value":"38","label":"38"},"6351":{"type":"0","value":"38,5","label":"38,5"},"6335":{"type":"0","value":"39","label":"39"},"6354":{"type":"0","value":"40","label":"40"},"6338":{"type":"0","value":"40,5","label":"40,5"},"6357":{"type":"0","value":"41","label":"41"},"6326":{"type":"0","value":"42","label":"42"},"6362":{"type":"0","value":"42,5","label":"42,5"},"6341":{"type":"0","value":"43","label":"43"},"6365":{"type":"0","value":"44","label":"44"},"6344":{"type":"0","value":"44,5","label":"44,5"},"6370":{"type":"0","value":"45,5","label":"45,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"},"205":{"6319":{"type":"0","value":"5,5","label":"5,5"},"6372":{"type":"0","value":"6,0","label":"6,0"},"6334":{"type":"0","value":"6,5","label":"6,5"},"6350":{"type":"0","value":"7,0","label":"7,0"},"6337":{"type":"0","value":"7,5","label":"7,5"},"6353":{"type":"0","value":"8,0","label":"8,0"},"6325":{"type":"0","value":"8,5","label":"8,5"},"6356":{"type":"0","value":"9,0","label":"9,0"},"6340":{"type":"0","value":"9,5","label":"9,5"},"6364":{"type":"0","value":"10,0","label":"10,0"},"6343":{"type":"0","value":"10,5","label":"10,5"},"6328":{"type":"0","value":"11,5","label":"11,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"},"204":{"6318":{"type":"0","value":"5,0","label":"5,0"},"6352":{"type":"0","value":"5,5","label":"5,5"},"6743":{"type":"0","value":"6,0-EU39","label":"6,0-EU39"},"6744":{"type":"0","value":"6,0-EU40","label":"6,0-EU40"},"6355":{"type":"0","value":"6,5","label":"6,5"},"6336":{"type":"0","value":"7,0","label":"7,0"},"6361":{"type":"0","value":"7,5","label":"7,5"},"6324":{"type":"0","value":"8,0","label":"8,0"},"6363":{"type":"0","value":"8,5","label":"8,5"},"6339":{"type":"0","value":"9,0","label":"9,0"},"6366":{"type":"0","value":"9,5","label":"9,5"},"6369":{"type":"0","value":"10,5","label":"10,5"},"additional_data":"{\"swatch_input_type\":\"text\",\"update_product_preview_image\":\"0\",\"use_product_image_for_swatch\":0}"}},
                "mediaCallback": "https\u003A\u002F\u002Fwww.bstn.com\u002Feu_en\u002Fswatches\u002Fajax\u002Fmedia\u002F",
                "gallerySwitchStrategy": "prepend",
                "jsonSwatchImageSizeConfig": {"swatchImage":{"width":30,"height":20},"swatchThumb":{"height":90,"width":110}},
                "showTooltip": 1  '''
match = re.search(r'"jsonConfig":\s*(.*})', string)
if match:
    js = json.loads(match.group(1))
    print(js["attributes"])

相关问题 更多 >

    热门问题