python如何从javascript中提取json

时间:2019-03-21 02:30:44

标签: python json parsing

从文本片段(在本例中为JavaScript)中提取json的Python方法是什么。 这是一个在文本中带有Json的js函数调用,我想将JSON提取出来并进行解析。我一直在使用正则表达式,但是如果更改了周围的文本,则必须更改它,并且必须弄乱诸如的转义字符。每一次。有一个更好的方法吗?

window._wq = window._wq || []; window._wq.push(function (W) { W.iframeInit({"assets":[{"type":"original","slug":"original","display_name":"Original file","width":1920,"height":1080,"size":491562565,"bitrate":2140,"public":true,"status":2,"progress":1.0,"url":"https://embed-ssl.wistia.com/deliveries/8137332c82d58a3207efafc.bin","created_at":1540249341},{"type":"iphone_video","slug":"mp4_h264_474k","display_name":"360p","container":"mp4","codec":"h264","width":640,"height":360,"ext":"mp4","size":109019112,"bitrate":474,"public":true,"status":2,"progress":1.0,"metadata":{},"url":"https://embed-ssl.wistia.com/deliveries/00a8759890e3d959ec72f101be.bin","created_at":1540249341,"segment_duration":3,"opt_vbitrate":1200}"flashPlayerUrl":"https://embed-ssl.wistia.com/flash/embed_player_v2.0.swf?2017-04-20","showAbout":true,"createdAt":1540249341,"firstEmbedForAccount":false,"firstShareForAccount":false,"useMediaDataHostLogic":true,"stats":{"loadCount":579,"playCount":232,"uniqueLoadCount":179,"uniquePlayCount":125,"averageEngagement":0.369201},"trackingTransmitInterval":59,"integrations":{"google_analytics":true},"hls_enabled":true,"embed_options":{"volumeControl":"true","fullscreenButton":"true","controlsVisibleOnLoad":"true","playerColor":"cccccc","bpbTime":"false","vulcan":"true","videoQuality":"","playsinline":true}}, {}); window._wistiaHasInitialized = true;

0 个答案:

没有答案