js解析为xml遇const报错

问题遇到的现象和发生背景

将string解析成xml报错

用代码块功能插入代码,请勿粘贴截图
def parse(self, response):
    # 解析json,获取某个变量var的值
    # /html/body/script[1]/text()
    print(1)
    json_str = response.xpath('//html/body/script[1]/text()').extract_first()

    demo = response.text
    soup = BeautifulSoup(demo, 'lxml')
    script = soup.select('body script')[0].string
    print(script)
    script_text = js2xml.parse(script, "text/xml")
    script_tree = js2xml.pretty_print(script_text)
    selector = etree.HTML(script_tree)
运行结果及报错内容

img

calmjs.parse.exceptions.ECMASyntaxError: Unexpected 'const' at 9:3 after ';' at 6:48

我想要达到的结果

正确解析

发现可能是版本问题,js2xml解析不了const关键字,然后我就直接粗暴的替换const为var ,然后正常解析。