如何解析HTML源與Python中的JavaScript代碼,例如我想提取的productList的對象解析JavaScript代碼的HTML源
這裏是我下面的來源;
<html>
<body>
<div id="content-wrapper" class="row-fluid clearfix" role="contentinfo">
<!-- html content -->
</div>
<script>
var productList = { "daaa" : "ddddd"};
</script>
</body>
</html>
這些幫助嗎? http://stackoverflow.com/questions/390992/javascript-parser-in-python http://stackoverflow.com/questions/18368058/how-can-i-parse-javascript-variables-using-python – 2014-11-24 21:41:40
一個問題你在某些時候可能會遇到'var productList = {daaa:function(){}};'是有效的JS,但不是有效的JSON。 – njzk2 2014-11-24 21:43:08